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:

load(queryParams)

Retrieves the given object from the Salesforce database.
Parameters:
Name Type Description
queryParams Object query parameters
Properties
Name Type Description
objName string the object/table name in the data store where the give object is to be updated
keyName string the key name to find the object to be updated
keyVal string the key value to find the object to be updated
query string the SOQL query, i.e. what gets executed is "SELECT "
filter string additional query results filter - this is added to the end of the SQL query
queryXtra string additional bits to be added to the end of the query, for example "LIMIT 100". "LIMIT 100" is auto added. Use false to prevent auto adding, for example when using aggregate queries. alternatively, can pass in params as: objName, keyName, keyVal, filter, queryXtra
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 Mon Jul 23 2018 23:46:45 GMT-0400 (EDT)