1. Home
  2. Docs
  3. Code
  4. ConversationHelper

ConversationHelper

ConversationHelper(logger, sdk)

new ConversationHelper(logger, sdk)

Get the sdk and logger for use
Parameters:
Name Type Description
logger Logger
sdk module

Methods

addAnythingElseMessage(res)

add anything else random message to be sent to the user at end of action
Parameters:
Name Type Description
res ConversationRequest the response object

askForEntity(context, expected, say, reprompt)

Ask the user for a specific entity
Parameters:
Name Type Description
context Object current information on the system context
expected Object the search keyword
say speech ask the user for an entity
reprompt speech ask the user again with an example

askForPIN(context, callback)

Asks the user for their pin if it’s missing
Parameters:
Name Type Description
context object current information on the system context
callback object helps define the execution order of functions with function calls within

clearAccountLinking(accessToken) → {json}

Clear the user account linking
Parameters:
Name Type Description
accessToken string the user specific token
Returns:
response true if user has proper pin and validation
Type
json

clearState(session)

Reset all stored session callbacks commands (yes , no , next request, cancel)
Parameters:
Name Type Description
session Object the user session information

EnterPINCode(context, req, res, callback)

Handle Pin Code Intent logic, activate next request it if it was defined
Parameters:
Name Type Description
context Object current request context
req ConversationRequest current request
res ConversationRequest current response
callback object – for getting the backend context

fetchUserContext(accessToken, PINCode) → {json}

User validation to ensure proper access
Parameters:
Name Type Description
accessToken string the user specific token
PINCode number the user’s PIN
Returns:
context response if user has proper pin and validation
Type
json

FillEntity(entities, context, req, res)

Check that the entity exists and that it is in the session
Parameters:
Name Type Description
entities Array.<Object> an array of entities in the skill
context object current information on the system context
req ConversationRequest current request
res ConversationRequest current response

findExpected(entities, req, expected) → {boolean}

Search for the expected entity name, if it exists set it as the targeted entity
Parameters:
Name Type Description
entities Array.<Object> an array of entities in the skill
req ConversationRequest current request
expected array expected entities to search
Returns:
true if the entity exists and false if it doesn’t
Type
boolean

getAnythingElseMessage() → {string}

return anything else random message to be sent to the user at end of action
Returns:
the message
Type
string

getBackendContext(context, callback) → {JSON}

Check for access token and backend context Ask for missing information if needed
Parameters:
Name Type Description
context object current information on the system context
callback object helps define the execution order of functions with function calls within
Returns:
backendContext
Type
JSON

getFallbackMessage() → {string}

return fallback random message to be sent to the user as fallback (no intent)
Returns:
the message
Type
string

onCancel(context, req, res)

Activate Cancel Intent logic, invoked session onCancel callback. In case no action needed close the session.
Parameters:
Name Type Description
context Object current request context
req ConversationRequest current request
res ConversationRequest current response

onFallback(context, req, res)

Handle Fallback Intent logic: add random Fallback message to the response
Parameters:
Name Type Description
context Object current request context
req ConversationRequest current request
res ConversationRequest current response

onNo(context, req, res)

Activate No Intent logic, invoked session onNo callback. In case no action needed close the session.
Parameters:
Name Type Description
context Object current request context
req ConversationRequest current request
res ConversationRequest current response

onYes(context, req, res)

Activate Yes Intent logic, invoked session yes callback or stored request
Parameters:
Name Type Description
context Object current request context
req ConversationRequest current request
res ConversationRequest current response

 

Was this article helpful to you? Yes No

How can we help?