|
|
QAPlugin API
|
|
|
===========
|
|
|
API.ai questions
|
|
|
---------------------
|
|
|
These are fancy questions. They are send to an online machine learning framework owned by Google (says enough) and allow for better pattern matching, context related conversations and online training so the questions can be matched better in the future. The disadvantage of this is that it requires a request to be send what can take about 100ms. It is recommended to prioritize the use of these types of questions.
|
|
|
|
|
|
**TIP**: There are a lot of examples available about these types of questions
|
|
|
https://www.spigotmc.org/resources/qaplugin-module-urbandictionary.34027/
|
|
|
https://www.spigotmc.org/resources/qaplugin-module-userdata.34215/
|
|
|
https://www.spigotmc.org/resources/qaplugin-module-mvdwtoggle.33713/
|
|
|
https://www.spigotmc.org/resources/qaplugin-module-plugininfo.33781/
|
|
|
https://www.spigotmc.org/resources/qaplugin-module-translate.33978/
|
|
|
|
|
|
To understand how to create questions for API.ai you need to get a basic understanding on how questions are made.
|
|
|
|
|
|
For more in depth information I advise you to look into the docs of API.ai: https://docs.api.ai/docs/key-concepts
|
|
|
The following is a quick TL;DR; of those docs.
|
|
|
|
|
|
### Entities
|
|
|
Entities are things in your question that need to be matched. If you are talking about a color, this is a **color entity**, if you are talking about a rank this is a **rank entity**. There are system entities which are basically pre defined entities that can match things like names, numbers, colors , ... . A full list of pre defined system entities can be found here. You may need this! https://docs.api.ai/docs/concept-entities#section-system-entities
|
|
|
|
|
|
As a developer you have the ability to program new entities. Note that they are uploaded so this means that you can't really update them fast.
|
|
|
#### When should I create my own entity?
|
|
|
If you need to match something that doesn't change often but doesn't have a system entity for it. For example the name of ranks, name of tiers, ... worlds ,... plugin names ,...
|
|
|
|
|
|
Entities can also make your life easier. Say you want to turn lights **on** and **off**. You could start creating two different questions for "on" and "off", but it may be better to create an entity for it called **on-off-state** that matches this.
|
|
|
A good example for that particular case is: https://www.spigotmc.org/resources/qaplugin-module-mvdwtoggle.33713/
|
|
|
|
|
|
### Intents
|
|
|
Intents = Questions. These are the questions you will create. Intents have the same construction as local question: They have possible 'templates' of what a user can say and they have a response that can contain parameters or text responses.
|
|
|
|
|
|
#### Intent template
|
|
|
These are templates of a what a user can say. They consist of multiple parts building up to one question.
|
|
|
"How are you" is one template
|
|
|
"Give me a @sys.color:color @item" are 3 parts, two being entities. But you will learn more about that later.
|
|
|
|
|
|
#### Intent Response
|
|
|
The response contains parameters that may or not be required. If a parameter is required it will prompt the user to provide these.
|
|
|
|
|
|
### Contexts
|
|
|
Last but not least we have conversation contexts. Contexts are things you are talking about. For example: If I ask you "Who is the US president?" and the answer is "Donald Trump", and I then ask "how tall is he?" - the framework still knows you are talking about "Donald Trump".
|
|
|
|
|
|
So contexts basically remember what you last talked about, but they can do way more than that with it.
|
|
|
|
|
|
###What will you need?
|
|
|
Everything related to API.ai questions is located in `be.maximvdw.qaplugin.api.*`
|
|
|
However if you are only interested in creating intents/entities and not responding to them
|
|
|
you will do with `be.maximvdw.qaplugin.api.ai.*`
|
|
|
|