Import Kompose Bot from file
Overview
Create your own JSON file and then import it to your Kompose bot.
The page will explain the template of the json file.
Details
The JSON file will be an object with one attribute "intents"
.
The value of this attribute will be an array:
{
"intents": [MyIntent,] // each intent in the array will be an object
}
Each value in this array will be a JSON
object and represents an intent for your Kompose BOT.
The structure of the object is:
{
"name": "order_details", // a unique name for your intent (string)
"category": "intent", // category of your intent, explained below (string)
"content": "", // actions of your intent e.g. bot replies, rich messages etc. (array)
"trainingPhrases": [""], // user messages that will trigger this intent (array)
"urlPatternList": [], // for welcome intents only (array)
"fields": {} // extract entities e.g. phone number, email etc. (object)
}
1. Types of Intents
Attribute: "category"
Value: <One of the strings mentioned below>
Each intent must have an attribute category
This attribute can have one of these four values:
a) Welcome event
"category": "welcome_event"
Adds a welcome event in the Kompose Bot. You don't need to provide training phrases for these types of intents as they are triggered directly.
You can have multiple intents of this type, but only one should be the default intent.
For all other "welcome_event"
, you should provide a valid UrlPatternList
value which is explained further in this document.
b) Answer
"category": "intent"
Adds an intent that is triggered based on the training phrases provided.
You can provide as many intents of this type as you want.
You can also extract entities in these intents. Read further to know more.
c) Small Talk
"category": "small_talk"
Adds a small talk type intent for your bot. You can provide as many intents of this type as you want.
d) Unknown User Input
"category": "fallback_intent"
Adds a fallback intent for your bot.
You don't need to provide training phrases for these types of intents as they are triggered directly.
Also, you can have only one intent of this type for your Kompose bot.
2. Intent Name
Attribute: "name"
Value: <A string with the name you want for the intent>
Provide the name you want for this intent.
NOTE: Each intent for your bot must have a unique name. So you can't use same name twice in your file and also you can't import intents with names already saved for your bot. If by mistake you import file with duplicate names, we will show you an error for the same.
3. Content
Attribute: "content"
Value: <An array defining all bot's reply>
This defines the action of the intent. This includes Bot's replies, Buttons, Rich Messages etc.
Your bot's reply can be text, buttons, image, rich messages, actions like assign to agent etc.
Just add the payload object you want in the array.
For Bots Text Reply
Add a text reply by adding this value to the array.
{"message":"Your message here"}
For Buttons
{
"message":"",
"platform":"kommunicate",
"metadata":
{
"contentType":"300","templateId":"6","payload":
[
{"title":"Button1","message":"Button1"},{"title":"Button2","message":"Button2"}
]
}
}
For Attachments
{
"message":"",
"platform":"kommunicate",
"metadata":
{
"contentType":"300",
"templateId":"9",
"payload":
[
{
"caption":"Your-Caption","url":"http://your-image-url.com"
}
]
}
}
Adding Custom Payloads
For adding custom payloads such as rich messages or custom actions. Refer to the pages rich messages and custom actions.
Add the payload object similar to the way above for text, buttons etc.
4. Training Phrases
Attribute: "trainingPhrases"
Value: <Array of strings>
These are the user messages that will trigger this intent.
This value will be an array of user messages that will trigger this intent.
e.g. ["show me the catalog", "i want my order details"]
NOTE: You can't have same user messages triggering multiple intents. So they should be unique and shouldn't be already saved for your bot.
5. Fields (Optional)
Attribute: "fields"
Value: <An object containing some key, value pairs defined below>
You can add this option to extract entities for your intent.
There are three inbuilt entities in Kompose Currently:
"email": "@KOMPOSE_DEFAULT_ENTITY.EMAIL"
"phoneNumber": "@KOMPOSE_DEFAULT_ENTITY.PHONE_NUMBER"
"url": "@KOMPOSE_DEFAULT_ENTITY.URL"
To add an entity add the above key value pairs in the object.
e.g.
{
"fields":
{
"email":"@KOMPOSE_DEFAULT_ENTITY.EMAIL",
"phoneNumber":"@KOMPOSE_DEFAULT_ENTITY.PHONE_NUMBER",
}
}
NOTE: Only for intents with training phrases
5. Welcome intent based on URL (optional)
Attribute: "urlPatternList"
Value: <An array of conditions to match>
If you want to have welcome events based on the page user is visiting. Use this attribute.
You will provide an array of conditions in this, the intent will be triggered if any of these conditions is satisfied.
A condition will look like
{
"type": 1 // can be either 1, 2, 3, 4
"pattern": "" // string to match
Type can have one of these four values:
type: 1
Will match if the page starts with the value provided in pattern.type: 2
Will match if the page contains the value provided in pattern.type: 3
Will match if the page ends with the value provided in pattern.type: 4
Will match if the page is equal to the value provided in pattern.
e.g. a condition
{
"type": 3
"pattern": "index.html"
}
means that it will be matched for all pages that ends with the string "index.html"
Sample JSON
{
"intents": [
{
"content": [
{
"message": "Hi. How can I help you?"
}
],
"urlPatternList": [],
"category": "welcome_event",
"name": "Default Welcome Intent",
"trainingPhrases": []
},
{
"content": [
{
"message": "Welcome to our orders page!"
}
],
"urlPatternList": [
{
"type": 1,
"pattern": "orders"
},
{
"pattern": "archived_orders",
"type": 4
}
],
"category": "welcome_event",
"name": "Orders Page",
"trainingPhrases": []
},
{
"content": [
{
"platform": "kommunicate",
"message": "our agents will get back to you",
"metadata": {
"KM_ASSIGN_TO": ""
}
}
],
"urlPatternList": [],
"category": "intent",
"name": "Assign to human",
"trainingPhrases": [
"talk to human",
"i need to talk to a real person"
]
},
{
"content": [
{
"message": "Here's a joke for you:"
}
],
"urlPatternList": [],
"category": "small_talk",
"name": "i am bored",
"trainingPhrases": [
"i am really bored"
]
},
{
"content": [
{
"message": "I can't understand what you are saying."
}
],
"urlPatternList": [],
"category": "fallback_intent",
"name": "Default Fallback Intent",
"trainingPhrases": []
}
]
}