6. template element¶
This chapter describes the AIML elements that can be described within the template element.
The following is a list of AIML elements that can be described within the template elements supported by the Dialog Platform.
- addtriple
- authorise
- bot
- button
- card
- carousel
- condition
- date
- delay
- deletetriple
- denormalize
- eval
- explode
- first
- extension
- formal
- gender
- get
- id
- image
- implode
- input
- interval
- json
- learn
- learnf
- li
- link
- list
- log
- lowercase
- map
- nluintent
- nluslot
- normalize
- oob
- olist
- person
- person2
- program
- random
- reply
- request
- resetlearn
- resetlearnf
- response
- rest
- set
- select
- sentence
- size
- space
- split
- sr
- srai
- sraix
- star
- system
- that
- thatstar
- think
- topicstar
- uniq
- uppercase
- video
- vocabulary
- word
- xml
6.1. Details¶
6.1.1. addtriple¶
[2.0]
The addtriple element adds the element (knowledge) to the RDF knowledge base. The element has 3 components: subject, predicate, and object. For more information about addtriple elements, see RDF support.
In the example below, for the user’s utterance “My favorite food is fish”, an element (knowledge) consisting of items subject = ‘My favorite food’, pred = ‘is’, object = ‘fish’ is registered in the RDF knowledge base.
- Use case
<?xml version="1.0" encoding="UTF-8"?>
<aiml version="2.0">
<category>
<pattern>* favorite food is * </pattern>
<template>
<addtriple>
<subj><star /> favorite food</subj>
<pred>is</pred>
<obj><star index="2"/></obj>
</addtriple>
Registered the preferences
</template>
</category>
</aiml>
See uniq, select to check the results of the registration.
See also: deletetriple, select, uniq, RDF support
6.1.2. authorise¶
[1.0]
The authorise element allows the user’s role to toggle the execution of AIML elements described within the template element. If the user’s role differs from the role specified in the root attribute of the authorise element, the AIML element described in the authorise element is not executed. See Security for more information.
- Attribute
Parameter | Type | Required | Description |
---|---|---|---|
role | String | Yes | Role Name |
denied_srai | String | No | Srai destination on authentication failure |
- Use case
This use case can return the contents of a vocabulary only if the user’s role is “root”.
<?xml version="1.0" encoding="UTF-8"?>
<aiml version="2.0">
<category>
<pattern>Number of vocabulary lists</pattern>
<template>
<authorise role="root">
<vocabulary />
</authorise>
</template>
</category>
</aiml>
In addition, you can specify the denied_srai attribute to determine the default behavior when the user’s role differs from the specified role.
<?xml version="1.0" encoding="UTF-8"?>
<aiml version="2.0">
<category>
<pattern>Number of vocabulary lists </pattern>
<template>
<authorise role="root" denied_srai="ACCESS_DENIED">
<vocabulary />
</authorise>
</template>
</category>
</aiml>
See also: Security
6.1.3. bot¶
[1.0]
Gets the properties specific to the bot. This element is read-only. These properties can be specified in properties.txt and read at startup to get as bot-specific information.
- Attribute
Parameter | Type | Required | Description |
---|---|---|---|
name | String | Yes | Basically, any of name, birthdate, app_version, grammar_version is described (possible to change in properties.txt). |
- Use case
<category>
<pattern>Who are you? </pattern>
<template>
My name is <bot name = "name" />.
I was born on <bot name = "birthdate" />.
The application version is <bot name="app_version" />.
The grammar version is <bot name="grammar_version" />.
</template>
</category>
You can use name as a child element of a bot to describe the same thing as the name attribute.
<category>
<pattern>Who are you? </pattern>
<template>
My name is <bot><name>name</name></bot>.
I was born on <bot><name>birthdate</name></bot>.
The application version is <bot><name>app_version</name></bot>.
The grammar version is <bot><name>grammar_version</name></bot>.
</template>
</category>
See also: File Management:properties
6.1.4. button¶
[2.1]
The button element is a rich media element used to prompt the user to tap during a conversation. Text used for the notation of button, postback for Bot, URL when button is pressed can be described as child elements.
- Child element
Parameter | Type | Required | Description |
---|---|---|---|
text | String | Yes | Describes the display text for the button. |
postback | String | No | Describes the operation when the button is pressed. This message is not shown to the user and is used to respond to a Bot or to process in an application. |
url | String | No | Describes the URL when the button is pressed. |
- Use case
<category>
<pattern>Transfer</pattern>
<template>
<button>
<text>Do you want to search for transfer? </text>
<postback>Transfer Guide </postback>
</button>
</template>
</category>
<category>
<pattern>Search</pattern>
<template>
<button>
<text>Do you want to search?</text>
<url>https://searchsite.com</url>
</button>
</template>
</category>
6.1.5. card¶
[2.1]
A card is a card that uses several other elements, such as images, buttons, titles, and subtitles. A menu containing all of these rich media elements appears.
- Child element
Parameter | Type | Required | Description |
---|---|---|---|
title | String | Yes | Describes the title of the card. |
subtitle | String | No | Provide additional information for the card. |
image | String | Yes | Describes the image URL etc. for the card. |
button | String | Yes | Describes the button information for the card. |
- Use case
<category>
<pattern>Search</pattern>
<template>
<card>
<title>Card Menu</title>
<subtitle>Card Menu Details</subtitle>
<image>https://searchsite.com/image.png</image>
<button>
<text>Do you want to search?</text>
<url>https://searchsite.com</url>
</button>
</card>
</template>
</category>
6.1.6. carousel¶
[2.1]
The carousel element uses several card elements to display a tap through menu. A menu containing all of these rich media elements appears.
- Child element
Parameter | Type | Required | Description |
---|---|---|---|
card | String | Yes | Specifies multiple cards. Display one card at a time and tap through to display another card. |
- Use case
<category>
<pattern>Restaurant Search</pattern>
<template>
<carousel>
<card>
<title>Italian</title>
<subtitle>Searching for Italian restaurants </subtitle>
<image>https://searchsite.com?q=italian</image>
<button>Italian Search </button>
</card>
<card>
<title>French</title>
<subtitle>Searching for French restaurants</subtitle>
<image>https://searchsite.com?q=french</image>
<button>French Search</button>
</card>
</carousel>
</template>
</category>
6.1.7. condition¶
[1.0]
- Attribute
Parameter | Type | Required | Description |
---|---|---|---|
name | variable name | No | Specifies the variable to be the branch condition. |
var | variable name | No | Specifies the variable to be the branch condition. |
data | variable name | No | Specifies the variable to be the branch condition. |
bot | property name | No | Specifies the Bot specific information for the branch condition. |
value | judgment value | No | Specifies the value for the branch condition. |
- Child element
Parameter | Type | Required | Description |
---|---|---|---|
li | String | No | Describes the branch condition for the specified variable. |
note : Each parameter of the attribute can also be specified as a child element.
6.1.7.1. Block Condition¶
- Use case
<condition name="property" value="v">X</condition>
<condition name="property"><value>v</value>X</condition>
<condition value="v"><name>property</name>X</condition>
<condition><name>property</name><value>v</value>X</condition>
6.1.7.2. Single-predicate Condition¶
In the example below, both conditions are syntactically equivalent and will return X if predicate called property has value a, and b if it has value Y, otherwise the statement will return the default value Z.
- Use case
<condition name="property">
<li value="a">X</li>
<li value="b">Y</li>
<li>Z</li>
</condition>
<condition>
<name>property</name>
<li value="a">X</li>
<li value="b">Y</li>
<li>Z</li>
</condition>
6.1.7.3. Multi-predicate Condition¶
- Use case
<condition>
<li name="1" value="a">X</li>
<li value="b"><name>1</name>Y</li>
<li name="1"><value>b</value>Z</li>
<li><name>1</name><value>b</value>Z</li>
<li>Z<l/i>
</condition>
6.1.7.4. Looping¶
In the following example, the variable “topic” is evaluated to determine what to return. If the branch condition is not match, “chat” is set to “topic”, <condition>is re-evaluated, and “chat” exits the loop.
- Use case
<condition var="topic">
<li value="flower">What flowers do you like ? </li>
<li value="drink">Do you like coffee ? </li>
<li value="chat">Did something good happen? </li>
<li><think><set var="topic">chat </set></think><loop/></li>
</condition>
6.1.8. date¶
[1.0]
- Attribute
Parameter | Type | Required | Description |
---|---|---|---|
format | String | No | Output format specification. If unspecified, %c. |
- Child element
Parameter | Type | Required | Description |
---|---|---|---|
format | String | No | Output format specification. If unspecified, %c. |
- Use case
<category>
<pattern>What's the date today? </pattern>
<template>
Today is <date format="%d/%m/%Y" />.
</template>
</category>
<category>
<pattern>What's the date today ?</pattern>
<template>
Today is <date><format>%d/%m/%Y</format></date>.
</template>
</category>
See also: interval
6.1.9. delay¶
[2.1]
The delay element is the delay factor. It is used to define the wait time during text-to-speech playback and to specify the delay of the Bot’s response to the user.
- Child element
Parameter | Type | Required | Description |
---|---|---|---|
seconds | String | Yes | Specifies the delay in seconds. |
- Use case
<category>
<pattern>Wait * seconds</pattern>
<template>
<delay>
<seconds><star/></seconds>
</delay>
</template>
</category>
6.1.10. deletetriple¶
[2.0]
- Use case
<category>
<pattern>Remove * is a * </pattern>
<template>
<deletetriple>
<subj><star /></subj>
<pred>isA</pred>
<obj><star index="2"/></obj>
</deletetriple>
</template>
</category>
See also: addtriple, select, uniq, RDF Support
6.1.11. denormalize¶
[1.0]
- Use case
<category>
<pattern>The URL is *.</pattern>
<template>
<think>
<set var="url"><normalize><star /></normalize></set>
</think>
Restore <denormalize><get var = "url" /></denormalize>.
</template>
</category>
<denormalize/>is equivalent to <denormalize><star/></denormalize>.
- Use case
<category>
<pattern>URL is * </pattern>
<template>
Restore <denormalize />.
</template>
</category>
See also: File Management : denormal, normalize
6.1.12. eval¶
[1.0]
Typically used as part of learn or learnf elements. Eval evaluates the contained elements returning the textualized content.
In the example below, if a variable with name ‘name’ was set to TIMMY, and a variable ‘animal’ was set to dog, then evaluation of this learn node would then see a new category ‘learnt’ to match ‘Who is TIMMY’ with a response, ‘Your DOG’.
- Use case
<category>
<pattern>Remember * is my pet * .</pattern>
<template>
Your pet is <star index = "2" /> <star />.
<think>
<set name="animal"><star /></set>
<set name="name"><star index="2" /></set>
</think>
<learnf>
<category>
<pattern>
<eval>
Who is
<get name="name"/>?
</eval>
</pattern>
<template>
Your
<eval>
<get name="animal"/>
</eval>
.
</template>
</category>
</learnf>
</template>
</category>
6.1.13. explode¶
[1.0]
Turns the contents of each word contained within the talk into a series single character words separated by spaces. So for example ‘FRED’ would explode to ‘F R E D’, and ‘Hello There’ would explode to ‘H e l l o T h e r e’.
- Use case
<category>
<pattern>EXPLODE *</pattern>
<template>
<explode><star /></explode>
</template>
</category>
<explode />is equivalent to <explode><star /></explode>.
<category>
<pattern>EXPLODE *</pattern>
<template>
<explode />
</template>
</category>
See also: implode
6.1.14. image¶
[2.1]
Use the image element to return image information. You can specify the image URL and file name.
<category>
<pattern>Image display </pattern>
<template>
<image>https://url.for.image</image>
</template>
</category>
6.1.15. first¶
[1.0]
- Use case
<category>
<pattern>My name is * </pattern>
<template>
Your first name is <first><star /></first>.
</template>
</category>
<first />is equivalent to <first><star /></first>.
- Use case
<category>
<pattern>My name is * </pattern>
<template>
Your first name is <first />.
</template>
</category>
See also: rest
6.1.16. extension¶
[custom]
It is an element that requires engine customization.
An extension provides the mechanism to call out to the underlying Python classes.
An extension is essentially made up of a full Python module path to a Python class which implements the programy.extensions.Extension
interface.
See Extensions for more information.
- Attribute
Parameter | Type | Required | Description |
---|---|---|---|
path | String | Yes | extension name used. |
- Use case
<category>
<pattern>
GEOCODE *
</pattern>
<template>
<extension path="programy.extensions.goecode.geocode.GeoCodeExtension">
<star />
</extension>
</template>
</category>
See also: Extensions
6.1.17. formal¶
[1.0]
The formal element will capitalise every distinct word contained between its elements.
- Use case
<category>
<pattern>My name is * *</pattern>
<template>
Hello Mr <formal><star /></formal> <formal><star index="2"/></formal>.
</template>
</category>
<formal />is equivalent to <formal><star /></formal>.
- Use case
<category>
<pattern>My name is * *</pattern>
<template>
Hello Mr <formal /><formal><star index="2"/></formal>
</template>
</category>
6.1.18. gender¶
[1.0]
- Use case
<category>
<pattern>Does it belong to *?</pattern>
<template>
No, it belongs to <gender><star/></gender>.
</template>
</category>
See also: File Management:gender
6.1.19. get¶
[1.0]
- Local Variables (var)
- Persistent Global Variables (name)
- Retain Range Global Variable (data)
- Attribute
Parameter | Type | Required | Description |
---|---|---|---|
name | Variable Name | Yes | var, name, or data must be set. |
var | Variable Name | Yes | var, name, or data must be set. |
data | Variable Name | Yes | var, name, or data must be set. |
- Child element
Parameter | Type | Required | Description |
---|---|---|---|
name | Variable Name | Yes | var, name, or data must be set. |
var | Variable Name | Yes | var, name, or data must be set. |
data | Variable Name | Yes | var, name, or data must be set. |
- Use case
<!-- Access Global Variable -->
<category>
<pattern>Today is * .</pattern>
<template>
<think><set name="weather"><star/></set></think>
Today's weather is <get name = "weather" />.
</template>
</category>
<!-- Access Local Variable -->
<category>
<pattern>Tomorrow is * .</pattern>
<template>
<think><set var="weather"><star/></set></think>
Today's weather is <get name="weather" />, tomorrow's weather is <get var = "weather" />.
</template>
</category>
<category>
<pattern>What's the weather? </pattern>
<template>
Today's weather is <get name = "weather" />, tomorrow's weather is <get var = "weather" />.
</template>
</category>
See also: set, File Management:properties
6.1.20. id¶
[1.0]
Returns the client name. The client name is specified by the client developer in Config.
- Use case
<category>
<pattern>What's your name? </pattern>
<template>
<id />
</template>
</category>
6.1.21. implode¶
[custom]
Given a string of words, concatenates them all into a single string with no spaces. If enable the implode, ‘c o f f e e’ will be transformed to ‘coffee’.
- Use case
<category>
<pattern>Implode *</pattern>
<template>
<implode><star /></implode>
</template>
</category>
<implode />is equivalent to <implode><star /></implode>.
- Use case
<category>
<pattern>Implode *</pattern>
<template>
<implode />
</template>
</category>
See also: explode
6.1.22. input¶
[1.0]
Returns the entire pattern sentences.
This is different to the wildcard <star/>
tag which only returns those values that match one of the wildcards in the pattern.
- Use case
<category>
<pattern>What was my question ?</pattern>
<template>
Your question was "<input />".
</template>
</category>
6.1.23. interval¶
[1.0]
- Child element
Parameter | Type | Required | Description |
---|---|---|---|
from | String | Yes | Describes the starting time of the calculation. |
to | String | Yes | Describes the final starting time of the calculation. |
style | String | Yes | The unit to return in interval. One of years, months, days, or seconds. |
- Use case
<category>
<pattern>How old are you? </pattern>
<template>
<interval format="%B %d, %Y">
<style>years</style>
<from><bot name="birthdate"/></from>
<to><date format="%B %d, %Y" /></to>
</interval>
years old.
</template>
</category>
See also: date
6.1.24. json¶
[custom]
- Attribute
Parameter | Set value | Type | Required | Description |
---|---|---|---|---|
name | JSON Name | Yes | Specify the JSON to parse. var, name, or data must be set. | |
var | JSON Name | Yes | Specify the JSON to parse. var, name, or data must be set. | |
data | JSON Name | Yes | Specify the JSON to parse. var, name, or data must be set. | |
function | Function Name | No | Describes the processing for JSON. | |
len | Function Name | No | If the JSON property is an array, gets array length. For JSON objects, get the number of elements in the JSON object. | |
delete | Function Name | No | Deletes the target property. If index is specified in the array, the target element is deleted. | |
insert | Function Name | No | Specifies the addition of a value to a JSON array. It is specified with an array number (index). | |
index | Index | No | Specifies the index when obtaining JSON data. If the target is an array, it is specified the array number. In a JSON object, it specifies the key count from the head. When setting or modifying JSON data, it can be specified only arrays. | |
item | Get key name | No | Used to get the key from JSON data. Specify this attribute to get keys instead of values. | |
key | Key specification | No | Specifies the key to manipulate JSON data. |
- Child element
Parameter | Type | Required | Description |
---|---|---|---|
function | Function name | No | Describes the processing for JSON. See the attribute’s function for its contents. |
index | Index | No | You can specify it for a JSON objects and an array. For an array, it specifies the array index and for a JSON objects, it specifies the key count from the beginning. When setting or modifying JSON data, you can only specify arrays. |
item | Get key name | No | Used to get the key from JSON data. Specify this attribute to get keys instead of values. |
key | Key specification | No | Specifies the key to manipulate the JSON data. |
- Use case
{
"transportation":{
"station":{
"departure":"Tokyo",
"arrival":"Kyoto"
},
"time":{
"departure":"11/1/2018 11:00",
"arrival":"11/1/2018 13:30"
}
}
}
As in the example above, if you want to return the transportation.station.separate, you can use the following:
<category>
<pattern>From Tokyo to Kyoto.</pattern>
<template>
Departure from <json var = "__SUBAGENT__.transit.transportation.station.departure" />.
</template>
</category>
6.1.25. learn¶
[2.0]
Because learnf is file preserving, it retains its state when the bot is restarted, but learn is initialized when the bot is restarted.
- Use case
<category>
<pattern>Remember * is my pet *.</pattern>
<template>
<think>
<set name="name"><star /></set>
<set name="animal"><star index="2" /></set>
</think>
<learn>
<category>
<pattern>
Who is
<eval>
<get name="name"/>
</eval>
?
</pattern>
<template>
Your
<eval>
<get name="animal"/>
</eval>.
</template>
</category>
</learn>
</template>
</category>
6.1.26. learnf¶
[2.0]
Since learnf is a file retention, it is reloaded when the bot is restarted.
- Use case
<category>
<pattern>Remember * is my pet *.</pattern>
<template>
<think>
<set name="name"><star /></set>
<set name="animal"><star index="2" /></set>
</think>
<learnf>
<category>
<pattern>
Who is
<eval>
<get name="name"/>
</eval>
?
</pattern>
<template>
Your
<eval>
<get name="animal"/>
</eval>
.
</template>
</category>
</learnf>
</template>
</category>
6.1.27. li¶
[1.0]
The li element describes the branch condition specified in <condition>. For detailed usage, see condition for more information.
- Child element
Parameter | Type | Required | Description |
---|---|---|---|
think | String | No | The definition which does not affect the action is described. |
set | String | No | Set variables. |
get | String | No | Gets the value of a variable. |
loop | String | No | Specifies a loop for <condition>. |
star | String | No | Reuse the input wildcards. |
6.1.28. link¶
[2.1]
The link element is a rich media element used for purposes such as URLs to display to the user during a dialog. Child elements can describe the text used to display or read, and the destination url.
- Child element
Parameter | Type | Required | Description |
---|---|---|---|
text | String | Yes | Describes the display text to the button. |
url | String | No | Describes the URL when the button is pressed. |
<category>
<pattern>Search</pattern>
<template>
<link>
<text>Search site</text>
<url>searchsite.com</url>
</link>
</template>
</category>
6.1.29. list¶
[2.1]
The list element is a rich media element that returns the elements described in item in list format. It can describe the contents of the list to the item of the child element. Also it is possible to nest the item with list.
Parameter | Type | Required | Description |
---|---|---|---|
item | String | Yes | Describes the contents of the list. |
<category>
<pattern>list</pattern>
<template>
<list>
<item>
<list>
<item>list item 1.1 </item>
<item>list item 1.2 </item>
</list>
</item>
<item>list item 2.1 </item>
<item>list item 3.1 </item>
</list>
</template>
</category>
6.1.30. log¶
[custom]
- Attribute
Parameter | Type | Required | Description |
---|---|---|---|
level | Variable Name | No | Specify error, warning, debug, info. The default output is info. |
See Log Settings for more information.
- Use case
<category>
<pattern>Hello</pattern>
<template>
Hello.
<log>Greetings</log>
</template>
</category>
<category>
<pattern>Goodbye</pattern>
<template>
Goodbye
<log level="error">Greetings</log>
</template>
</category>
See also: Log Settings
6.1.31. lowercase¶
[1.0]
Changes half-width alphabetic characters to lowercase.
- Use case
<category>
<pattern>HELLO * </pattern>
<template>
HELLO <lowercase><star /></lowercase>
</template>
</category>
<lowercase />is equivalent to <lowercase><star /></lowercase>.
- Use case
<category>
<pattern>HELLO *</pattern>
<template>
HELLO <lowercase />
</template>
</category>
See also: uppercase
6.1.32. map¶
[1.0]
- Attribute
Parameter | Type | Required | Description |
---|---|---|---|
name | Variable Name | Yes | Specifies the map file name. |
- Use case
<category>
<pattern>Where is the prefectural capital of *? </pattern>
<template>
<map name="prefectural_office"><star/></map>です。
</template>
</category>
See also: File Management:maps
6.1.33. nluintent¶
[custom]
- Attribute
Parameter | Type | Required | Description |
---|---|---|---|
name | Intent Name | Yes | Specify the intent name to get. * is treated as a wildcard. When a wildcard is specified, the index specifies what to get. |
item | Get Item Name | Yes | Gets information about the specified intent. The intent , score and count can be specified.
If intent is specified, the intent name can be obtained. When score is specified, the confidence level (0.0 ~ 1.0) is obtained. The count returns the number of intent names. |
index | Index | No | Specifies the index number of the intent to get. The index is for the list that only includes the intents matching with intent name specified by name. |
- Child element
Parameter | Type | Required | Description |
---|---|---|---|
name | Intent Name | Yes | Specifies the name of the intent to get. See the attribute’s name for its contents. |
item | Get Item Name | Yes | Gets information about the specified intent. See the attribute item for its contents. |
index | Index | No | Specifies the index number of the intent to get. See the index of the attribute for its contents. |
- Use case
Get information from NLU processing results. In the following example, the intent is obtained from the NLU processing result.
{
"intents": [
{"intent": "restaurantsearch", "score": 0.9 },
{"intent": "aroundsearch", "score": 0.4 }
],
"slots": [
{"slot": "genre", "entity": "Italian", "score": 0.95, "startOffset": 0, "endOffset": 5 },
{"slot": "genre", "entity": "French", "score": 0.86, "startOffset": 7, "endOffset": 10 },
{"slot": "genre", "entity": "Chinese", "score": 0.75, "startOffset": 12, "endOffset": 14 }
]
}
To get the intent processed by the NLU. Describe as follows.
<category>
<pattern>
<nlu intent="restaurantsearch"/>
</pattern>
<template>
<nluintent name="restaurantsearch" item="score"/>
</template>
</category>
See also: NLU 、 get the NLU Intent
6.1.34. nluslot¶
[custom]
- Attribute
Parameter | Type | Required | Description |
---|---|---|---|
name | Slot Name | Yes | Specifies the slot name to get. * is a wildcard. When a wildcard is specified, index specifies what to get. |
item | Get Item Name | Yes | Gets information about the specified slot. It can be specified slot , entity , score ,``startOffset`` , endOffset and count .
When slot is specified, gets the slot name. If entity is specified, gets the extracted string of the slot, if score is specified, gets the confidence level (0.0 ~ 1.0), if startOffset is specified, gets the start character position of the extracted string, and if endOffset is specified, gets the end character position of the extracted string.
The count returns the number of identical slot names. |
index | Index | No | Specifies the index number of the slot to gets. Specifies the index number in the list that matches the slot name specified by name. |
If an AIML variable is specified as a value, it cannot be specified in the attribute, so it can also be specified as a child element. The behavior is the same as the attribute. If it specifies the same attribute name and child element name, the child element setting takes precedence.
- Child element
Parameter | Type | Required | Description |
---|---|---|---|
name | Slot Name | Yes | Specifies the slot name to get. See the attribute’s name for its contents. |
item | Get Item Name | Yes | Gets information about the specified slot. See the attribute item for its contents. |
index | Index | No | Specifies the index number of the slot to get. See the index of the attribute for its contents. |
- Use case
Get slot information from NLU processing result. This section explains how to obtain a slot from the NLU processing result in the following example.
{
"intents": [
{"intent": "restaurantsearch", "score": 0.9 },
{"intent": "aroundsearch", "score": 0.4 }
],
"slots": [
{"slot": "genre", "entity": "Italian", "score": 0.95, "startOffset": 0, "endOffset": 5 },
{"slot": "genre", "entity": "French", "score": 0.86, "startOffset": 7, "endOffset": 10 },
{"slot": "genre", "entity": "Chinese", "score": 0.75, "startOffset": 12, "endOffset": 14 }
]
}
If you want to get the slots from NLU processing result, describe as follows.
<category>
<pattern>
<nlu intent="restaurantsearch"/>
</pattern>
<template>
<nluslot name="genre" item="count" />
<nluslot name="genre" item="entity" index="0"/>
<nluslot name="genre" item="entity" index="1"/>
<nluslot name="genre" item="entity" index="2"/>
</template>
</category>
See also: NLU 、 Get NLU Slot
6.1.35. normalize¶
[1.0]
Transforms symbols in the target string or abbreviated string to the specified word. The transformation contents are specified in normal.txt. For example, if ‘.’ is transformed to’ dot ‘and’ * ‘is transformed to’ _ ‘, then ‘ www.***.com’ will be transformed to ‘www dot _ _ _ dot com’.
- Use case
<category>
<pattern>URL is * </pattern>
<template>
Displays <normalize><star /></normalize>.
</template>
</category>
<normalize />is equivalent to <normalize><star /></normalize>.
- Use case
<category>
<pattern>URL is * </pattern>
<template>
Displays <normalize />.
</template>
</category>
See also: File Management:normal , denormalize
6.1.36. olist¶
[2.1]
The olist (ordered list) element is a rich media element that returns the elements listed in item. The item of the child element can contain the contents of the list. You can also nest item with list.
Parameter | Type | Required | Description |
---|---|---|---|
item | String | Yes | Describe the contents of the list. |
<category>
<pattern>Display the list</pattern>
<template>
<olist>
<item>
<card>
<image>https://searchsite.com/image0.png</image>
<title>Image No.1</title>
<subtitle>Tag olist No.1</subtitle>
<button>
<text>Yes</text>
<url>https://searchsite.com:?q=yes</url>
</button>
</card>
</item>
<item>
<card>
<image>https://searchsite.com/image1.png</image>
<title>Image No.2</title>
<subtitle>Tag olist No.2</subtitle>
<button>
<text>No</text>
<url>https://searchsite.com:?q=no</url>
</button>
</card>
</item>
</olist>
</template>
</category>
See also: card
6.1.37. oob¶
[1.0]
OOB stands for “Out of Band” and when the oob element is evaluated, the corresponding internal module performs processing and returns the processing result to the client. The processing in the internal module is actually intended for equipment operation and is intended for use in embedded devices. The internal modules that handle OOB are designed and implemented by system developers. See OOB for more information.
- Use case
<category>
<pattern>DIAL *</pattern>
<template>
<oob><dial><star /></dial></oob>
</template>
</category>
6.1.38. person¶
[1.0]
- Use case
<category>
<pattern>I am waiting for * .</pattern>
<template>
You are waiting for <person><star /></person>.
</template>
</category>
<person />is equivalent to <person><star /></person>.
- Use case
<category>
<pattern>I am waiting for * .</pattern>
<template>
You are waiting for <person />.
</template>
</category>
See also: File Management:person , person2
6.1.39. person2¶
[1.0]
- Use case
<category>
<pattern>Please tell * *. </pattern>
<template>
I tell <person2><star/></person2> <star index="2" />.
</template>
</category>
<person2 />is equivalent to <person 2><star /></person 2>.
- Use case
<category>
<pattern>Please tell * *. </pattern>
<template>
I tell <person2 /> <star index="2" />.
</template>
</category>
See also: File Management:person2 , person
6.1.40. program¶
[1.0]
Returns the program version of the Bot specified in Config.
- Use case
<category>
<pattern>version</pattern>
<template>
<program />
</template>
</category>
6.1.41. random¶
[1.0]
Randomly selects the <li> elements used by <condition>.
- Use case
<category>
<pattern>Hello</pattern>
<template>
<random>
<li>Hello</li>
<li>How are you today?</li>
<li>Shall I check today's schedule?</li>
</random>
</template>
</category>
6.1.42. reply¶
[2.1]
The reply element is a rich media element similar to the button element. As a child element, you can write the text you want to use for reading and the postback to the Bot. The difference between reply and button is that reply is intended to be used for voice interaction instead of GUI.
- Child element
Parameter | Type | Required | Description |
---|---|---|---|
text | String | Yes | Describe text-to-speech text. |
postback | String | No | Describe the operation. This message is not shown to the user and is used to respond to a Bot or to make some process in an application. |
- Use case
<category>
<pattern>Transfer </pattern>
<template>
<reply>
<text>Do you want to do a transfer search?</text>
<postback>Transfer Guide </postback>
</reply>
</template>
</category>
6.1.43. request¶
[1.0]
Returns the input history. The index attribute specifies the history number. 0 is the current input, and the higher the number, the more past history. This returns all sentences in an input if the input has multiple sentences.
- Attribute
Parameter | Type | Required | Description |
---|---|---|---|
index | String | No | Index number. 0 is the current index number, an alternative form with no attributes implies the use of index=‘1’. |
- Use case
<category>
<pattern>What did I say?</pattern>
<template>
You said <request index="1" /> and before that
you said <request index="2" /> and you just said
<request index="0" />.
</template>
</category>
<request />is equivalent to <request index=”1” />.
- Use case
<category>
<pattern>What did I say?</pattern>
<template>
You said <request />.
</template>
</category>
See also: response
6.1.44. resetlearn¶
[2.x]
Clears all categories enabled in the <learn>
<learnf>
elements.
- Use case
<category>
<pattern>Forget what I said.</pattern>
<template>
<think><resetlearn /></think>
OK, I have forgotten what you taught me.
</template>
</category>
6.1.45. resetlearnf¶
[2.x]
Clears all categories enabled in the <learn>
<learnf>
elements.
This differs from resetlearn in that it deletes all the files that the learnf element created.
- Use case
<category>
<pattern>Forget what I said. </pattern>
<template>
<think><resetlearnf /></think>
OK, I have forgotten what you taught me.
</template>
</category>
6.1.46. response¶
[1.0]
Returns the output history. The index attribute specifies the history number. The higher the number, the more past history. This returns all sentences if a multi sentence question is asked.
- Attribute
Parameter | Type | Required | Description |
---|---|---|---|
index | String | No | Index number. An alternative form with no attributes implies the use of index=‘1’. |
- Use case
<category>
<pattern>What did you just say?</pattern>
<template>
I said <response index="1" />and before that
I said <response index="2" />.
</template>
</category>
<response />is equivalent to <response index = “1” />.
- Use case
<category>
<pattern>What did you just say? </pattern>
<template>
I said <response/>.
</template>
</category>
See also: request
6.1.47. rest¶
[2.0]
- Use case
<category>
<pattern>My name is * .</pattern>
<template>
Your name is <rest><star /></rest>.
</template>
</category>
See also: first
6.1.48. set¶
[1.0]
The set elements in the template can set global and local variables. For differences in the variable type: name/var/data, see get.
- Use case
<!-- global variables -->
<category>
<pattern>MY NAME IS *</pattern>
<template>
<set name="myname"><star /></set>
</template>
</category>
<!-- local variables -->
<category>
<pattern>MY NAME IS *</pattern>
<template>
<set var="myname"><star /></set>
</template>
</category>
See also: get
6.1.49. select¶
[2.0]
- Use case
<category>
<pattern>* legs animals?</pattern>
<template>
<select>
<vars>?name</vars>
<q><subj>?name</subj><pred>legs</pred><obj><star/></obj></q>
</select>
</template>
</category>
<category>
<pattern>How many legs animals have?</pattern>
<template>
<select>
<vars>?name ?number</vars>
<q><subj>?name</subj><pred>legs</pred><obj>?number</obj></q>
</select>
</template>
</category>
See also: addtriple, deletetriple, uniq, RDF Support, File Management:rdfs
6.1.50. sentence¶
[1.0]
Capitalises the first word of the sentence and sets all other words to lowercase.
- Use case
<category>
<pattern>Create a sentence with the word *</pattern>
<template>
<sentence>HAVE you Heard ABouT <star/></sentence>
</template>
</category>
<sentence />is equivalent to <sentence><star /></sentence>.
- Use case
<category>
<pattern>CORRECT THIS *</pattern>
<template>
<sentence />
</template>
</category>
6.1.51. size¶
[1.0]
Returns the number of categories in the Bot.
- Use case
<category>
<pattern>How many categories do you understand? </pattern>
<template>
<size />.
</template>
</category>
6.1.52. space¶
[custom]
The space element inserts a halfwidth space when the sentence is created.
<category>
<pattern>Good morning.</pattern>
<template>
<think>
<set var="french">French</set>
<set var="italian">Italian</set>
<set var="chinese">Chinese</set>
</think>
Search <get var="french"/>,<get var="italian"/>,<get var="chinese"/>.
Search <get var="french"/><space/><get var="italian"/><space/><get var="chinese"/>.
</template>
</category>
6.1.53. split¶
[2.1]
The split element is used to split the Bot’s response into multiple parts. Split messages are treated as separate messages.
<category>
<pattern>Good morning.</pattern>
<template>
The weather is nice today.
<split/>
I hope it will be fine again tomorrow.
</template>
</category>
6.1.54. sr¶
[1.0]
Shorthand for <srai><star/></srai>
.
- Use case
<category>
<pattern>My question is * </pattern>
<template>
<sr />
</template>
</category>
<sr />is equivalent to <srai><star /></srai>.
<category>
<pattern>My question is * </pattern>
<template>
<srai><star/></srai>
</template>
</category>
6.1.55. srai¶
[1.0]
The srai element allows your bot to recursively call categories after transforming the user’s input. So you can define a template that calls another category. The acronym “srai” has no official meaning, but is sometimes defined as symbolic reduction or symbolic recursion.
- Use case
<category>
<pattern>Hello</pattern>
<template><srai>HI</srai></template>
</category>
<category>
<pattern>Ciao</pattern>
<template><srai>HI</srai></template>
</category>
<category>
<pattern>Hola</pattern>
<template><srai>HI</srai></template>
</category>
<category>
<pattern>HI</pattern>
<template>Hello</template>
</category>
6.1.56. sraix¶
[2.0]
Call any external REST API. Used for SubAgent calls. See SubAgent for more information on using sraix.
- Attribute
Parameter | Type | Required | Description |
---|---|---|---|
service | String | No | The service name of the custom external service. |
botid | String | No | The bot ID published on the Dialog Platform. |
- Use case
<category>
<pattern>Transfer information from * to *.</pattern>
<template>
<sraix service="myService">
<star/>
<star index="2"/>
</sraix>
</template>
</category>
6.1.57. star¶
[1.0]
*
and _
the zero or more characters ^
and #
, and index(1~) is displayed in order from the beginning.set
, iset
, regex
, bot
and bot elements of pattern elements.- Attribute
Parameter | Type | Required | Description |
---|---|---|---|
index | String | No | Input number. An alternative form with no attributes implies the use of index=‘1’. |
- Use case
<category>
<pattern>I like * and * .</pattern>
<template>
You like <star /> and <star index = "2" />.
</template>
</category>
6.1.58. system¶
[1.0]
The system element allows you to make underlying system calls. This is obviously a security concern allowing users unfettered access to the underlying system if they know the operating system and can inject shell scripts.
By default this is disabled, but can be turned on by setting the configuration optionallow_system_aiml
to True.
- Use case
<category>
<pattern>LIST ALL AIML FILES</pattern>
<template>
<system>ls -l *.aiml</system>
</template>
</category>
6.1.59. that¶
[1.0]
The that element is also defined as a child element of category
, and is used to match the bot’s previous response,
but if specified as a template element, that acts as an element that
retrieves past response statements from the bot.
- Attribute
Parameter | Type | Required | Description |
---|---|---|---|
index | String | No | Input number. An alternative form with no attributes implies the use of index=‘1’. |
- Use case
<category>
<pattern>Hello.</pattern>
<template>
Hello.
</template>
</category>
<category>
<pattern>Pardon?</pattern>
<template>
I said <that/>
</template>
</category>
See also: that(pattern), thatstar, topicstar
6.1.60. thatstar¶
[1.0]
pattern
element. These matches are accessed in the same way as using <star />
, but for that element, we use <thatstar />
.- Attribute
Parameter | Type | Required | Description |
---|---|---|---|
index | String | No | Input number. An alternative form with no attributes implies the use of index=‘1’. |
- Use case
<category>
<pattern>...</pattern>
<template>
Do you like coffee?
</template>
</category>
<category>
<pattern>Yes.</pattern>
<that>Do you like * ? </that>
<template>
I like <thatstar />, too.
</template>
</category>
See also: that(pattern), that, topicstar
6.1.61. think¶
[1.0]
The think element allows your bot to set predicates without actually displaying the contents of a set element to the user. This is sometimes referred to as “silently” setting a predicate.
- Use case
<category>
<pattern>My name is * </pattern>
<template>
<think><set name="name"><star /></set></think>
I remembered your name.
</template>
</category>
6.1.62. topicstar¶
[1.0]
topic
.<star />
, but for the topic, we use <topicstar />
.- Attribute
Parameter | Type | Required | Description |
---|---|---|---|
index | String | No | Input number. An alternative form with no attributes implies the use of index=‘1’. |
- Use case
<category>
<pattern>I like coffee. </pattern>
<template>
<think><set name="topic">beverages coffee </set></think>
OK.
</template>
</category>
<topic name="beverages *">
<category>
<pattern>What's my favorite drink?</pattern>
<template><topicstar/>. </template>
</category>
</topic>
See also: topic(pattern), thatstar
6.1.63. uniq¶
[2.0]
- Use case
<category>
<pattern>* are * </pattern>
<template>
<addtriple>
<subj><star /></subj>
<pred>are </pred>
<obj><star index="2"/></obj>
</addtriple>
Registered
</template>
</category>
<category>
<pattern>Search * * * </pattern>
<template>
<uniq>
<subj><star /></subj>
<pred><star index="2"/></pred>
<obj><star index="3"/></obj>
</uniq>
</template>
</category>
See also: addtriple, deletetriple, select, RDF Support, File Management:rdfs
6.1.64. uppercase¶
[1.0]
Capitalises half-width alphabetic characters.
- Use case
<category>
<pattern>Hello * </pattern>
<template>
Hello <uppercase><star /></uppercase>
</template>
</category>
<uppercase />is equivalent to <uppercase><star /></uppercase>.
- Use case
<category>
<pattern>Hello * </pattern>
<template>
Hello <uppercase />
</template>
</category>
See also: lowercase
6.1.65. vocabulary¶
[1.0]
Returns the number of distinct words known by the Bot.
- Use case
<category>
<pattern>How many words do you know? </pattern>
<template>
<vocabulary />.
</template>
</category>
See also: size
6.1.66. video¶
[2.1]
If this uses the video element, returns the video information. You can specify a URL or a file name for the video.
- Use case
<category>
<pattern>Video Display </pattern>
<template>
<video>https://url.for.video</video>
</template>
</category>
6.1.67. word¶
[1.0]
A <word>
tag as such does not exist, but each individual text word in a sentence is converted into a word node.
- Use case
<category>
<pattern>HELLO</pattern>
<template>Hi there!</template>
</category>
In this use case, HELLO is expanded to the word node.
6.1.68. xml¶
[1.0]
Like a word node, there is not <XML>
tag as such however given that AIML is an XML dialect, and if the parser comes across an xml element it does not undertand, it stores it as pure XML.
- Use case
<category>
<pattern>HIGHLIGHT * IN BOLD</pattern>
<template>
<bold><star /></bold>
</template>
</category>