System intents are intents defined in a custom package and are represented by the \Convo\Core\Intent\SystemIntent class. As you might see if you open that class, system intent can hold an intent definition for the particular platform SystemIntent::getPlatformModel(). Just a reminder that the \Convo\Core\Intent\IntentModel can be defined as custom intent or platform system intent, meaning that you can define your package intent which will be defined as system intent on one platform and custom intent for another platform.
If you are using \Convo\Core\Factory\AbstractPackageDefinition as your base class, you can define your intents as in a .json
file. This .json file has the following structure:
Each intent has an array of definition objects. Per definition object you may define which platforms this model applies to (used during propagation to specific platforms), with currently supported platforms being “Dialogflow” and “Amazon”. The definition itself consists of the intent’s platform name, and, if you wish to create your own custom intents, it must have a “type” property with the value “custom”.
“utterances” is an array of utterance objects. Each object has a “raw” utterance in its entirety, and then an array of parts called “model”.
As an example, let’s use a sentence with a slot value, e.g. “Today I want to eat {food}”. A specific example could be “Today I want to eat shrimp”. We split the sentence into two parts: “Today I want to eat”, which is just bog-standard text with no additional meaning, and “shrimp”, which is a possible slot value. Here is an example intent defined for Dialogflow:
Note how the part of the sentence that is a slot value has additional properties. In addition to the “text” part, you also define the slot’s “type”, which should be an entity that is available in your system. Lastly, “slot_value” determines the name under which the parsed slot value will be available for you to use in the editor. In this case, you would access the parsed value with ${result.foodName}.
Once you have defined all the intents you need, you must register them in your package. To do this, implement \Convo\Core\Intent\ISystemIntentRepository in your package definition class. Initialize your intents by overriding the _initIntents() method. You can return the result of _loadIntents() method from the parent abstract class and give it the namespace path to your .json intent definition file. For example, if your package is \Convo\Pckg\Acme\AcmePackageDefinition, and you followed the guidelines by placing the intent definition file in the same directory (suppose it is called just intents.json), give the _loadIntents() method the path ‘Convo/Pckg/Acme/intents.json’. This will parse and load the intents you have defined, making them available for usage.