Constructor
new Response()
Constructed by the ConversationEngine before calling a Voice Script's
intent or when trying to resolve a goal
Methods
addGoal()
Tells Violet that a goal needs to be met. These goals can be checked
to see if they are set by calling *hasGoal* and can be cleared by
calling *clearGoal*.
Once called Violet will call any defined goals after the current *resolve* method finishes.
Once called Violet will call any defined goals after the current *resolve* method finishes.
ask(potResponses)
Asks the user a question. Items being asked are placed after the say
statements. Additionally, only one ask is done at a time, giving the
user time to respond.
Parameters:
Name | Type | Description |
---|---|---|
potResponses |
Array.<string> | response or array of potential questions for the user |
clear(varStr)
Clears parameter that might have been gotten from the user
Parameters:
Name | Type | Description |
---|---|---|
varStr |
string | variable name |
clearAllGoals()
Clears all goals
clearGoal()
Clears goals
endConversation()
Ends the conversation after the response. By default Violet assumes
that you want to close the conversation.
- Default Value:
- keepConversationRunning=false
- Source:
get(varStr)
Gets parameter from the user
Parameters:
Name | Type | Description |
---|---|---|
varStr |
string | variable name |
Example
violet.respondTo({
expecting: 'My age is [[age]]',
resolve: (response) => {
var age = response.get('age');
if (age && age<17)
response.say('I need to be careful, you are a minor');
else
response.say('Good to meet you. I will remember the you are [[age]]');
}});
hasGoal()
Checks if a goal has been set.
keepConversationRunning()
Keeps the conversation after the response. By default Violet assumes
that you want to close the conversation.
- Default Value:
- keepConversationRunning=false
- Source:
say(potResponses, quickopt)
Responds to the user. When an array is provided Violet picks a
random item - this allows responses to not be repetitive. Additionally
you can add input parameters directly in the response by adding them
in [[]]
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
potResponses |
Array.<string> | response or array of potential responses for the user | ||
quick |
boolean |
<optional> |
false | do not put a pause between the previous say statement and this one |
Example
response.say('Hello')
response.say(['Hello', 'Hi'])
response.say('I like the name [[name]]')
set(varStr, val)
Sets parameter value for access later
Parameters:
Name | Type | Description |
---|---|---|
varStr |
string | variable name |
val |
Object | value attached to the variable |