I spend quite a lot of time on the Spigot developers forums, and one thread caught my attention. Coincidentally, I’m working on the same project the thread author started months ago (under a network). He was looking for some help with getting a service called DialogFlow to integrate with his Minecraft network.DialogFlow is a service by Google which integrates with things like Google Home and Amazon Alexa to allow users to ask questions and for custom services to handle the response.
The way it works is the developer creates an “intent”, an action/question that a user can ask. They can then add parameters to the intent which are automatically parsed from the question and sent over to your handling server. In this case, the author wanted to allow users to ask “how many players are on server <x>?”. The intent could be called “PlayerCount”, and the parameter would be the server (<x>).
After giving it a few training phrases (and selecting the parameter from those phrases), it gets really good at recognizing which word is the correct parameter.Once it’s parsed the question correctly, it then sends a request to your webhook. A webhook is a URL that data can be sent to by a service, usually an update or notification, which is then handled by the service. DialogFlow sends the Intent name, parameter(s), the full phrase, and other data to your webhook server, which then checks the given server player count and sends back data with whatever response you want.
This is the first time I’ve done HTTP backend in Java/Kotlin, so I used a library called Spark to simplify things (as opposed to using the builtin HTTP library).