Class: Response

response~Response()

The Response class that forwards requests to the ConversationEngine's OutputMgr which in turn will respond back to the calling-server and therefore the user.

Constructor

new Response()

Constructed by the ConversationEngine before calling a Voice Script's intent or when trying to resolve a goal
Source:

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.
Source:

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
Source:

clear(varStr)

Clears parameter that might have been gotten from the user
Parameters:
Name Type Description
varStr string variable name
Source:

clearAllGoals()

Clears all goals
Source:

clearGoal()

Clears goals
Source:

endConversation()

Ends the conversation after the response. By default Violet assumes that you want to keep the conversation open.
Default Value:
  • keepConversationRunning=true
Source:

get(varStr)

Gets parameter from the user
Parameters:
Name Type Description
varStr string variable name
Source:
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.
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
Source:
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
Source:
Documentation generated by JSDoc 3.5.5 on Sun Apr 29 2018 20:14:18 GMT-0400 (EDT)