The Response system operation is used to either provide a response to the user for a query, or to prompt the user to provide any sort of information. Shown below is an example of the Response operation being used in the WelcomeIntent intent by the application to greet the user.
var response = new Response;
response.responseSet = [
"Hello, how may I help you?",
"Hello, what can I help you with?",
"Hello, how may I be of assistance?",
"Hello"
];
response.userAction = "info";
response.send;
The responseSet property holds a set of responses the system could provide to the user in the form of an array. Every element inside the array must be a string.
When the application sends a response to the user, it selects a response from the array at random and displays it. The option to allow multiple responses to be provided instead of one is to make the conversational system look more human, such that it provides more diverse responses. Therefore, it is recommended that we should provide as many responses as possible.
Below is an example of a set of responses that could be used by a business to greet its customers.
response.responseSet = [
"Hello, how may I help you?",
"Hello, what can I help you with?",
"Hello, how may I be of assistance?",
"Hello"
];
The user action property lets the application know the type of response we are expecting from the user. There are 5 types of actions the system can expect from the user.
Action | Description | Possible use cases |
command | The response provided by the user to the query is to be taken in as a string value | Requesting an address, phone number, etc. |
confirm | The user responds with a confirmation (yes, no, or I don't know) | System requesting to verify some information provided |
answer | The user is requested to specify a slot value | When a value for a slot was not provided when the intent was triggered, but the application needs it to assist the user fulfil their goal |
select | Provides the user with a set of option to select from | Asking the user which size for a pizza order they would prefer (small, medium, or large) |
info | The application does not expect a response from the user. | Greeting, acknowledgement from the system, etc. |
A value for the options property must only be provided if the userAction is select. In this case, we must provide an object, with key-value pairs which map an option with a set of sample utterances.
In the PizzaShop sample application, the system prompts the user for which size they want their pizza order, and provides each option with a set of sample utterances (array of strings) the user might make to request that size option.
sizeResponse.options = {
Personal : [
"I would like a personal pizza",
"Give me a personal pizza",
"Personal please",
"Personal"
],
Medium : [
"I would like a medium pizza",
"Give me a medium pizza",
"Medium please",
"Medium"
],
Large : [
"I would like a large pizza",
"Give me a large pizza",
"Large please",
"Large"
]
};
The send operation takes the properties of the Response system operation into consideration, and sends the message to the user, and waits for the user to respond. The operation returns values of different data types, depending on the provided userAction property.
Action | Return type | Return information |
command | string | Exact response provided by the user as a string |
confirm | integer |
-1: undecided (I don't know) 0: denied (no) 1: accepted (yes) 2: unable to identify |
answer | string, integer, float, DateTime |
string: custom slot type integer, float: number slot type DateTime: datetime slot type |
select | string | Selected option as a string |
info | null | Does not return anything as a response from the user is not expected |
The next part discusses the implementation of the File system operation.