Next Prompt Sequence Snippet

Use this code with Studio actions that have the nextPromptSequence property, such as the Cloud Transcribeaction or the Voicebot Exchangeaction.

Code for CLOUD TRANSCRIBE

When using Turn-by-Turn Transcription, the utterance to be transcribed is stored in the variable specified in the transcriptVarName (out) property of the Cloud Transcribe action. If you're using the transcribed content to enable a text virtual agent to handle voice interactions, you need to: 

  • Configure the transcriptVarName (out) property with the name of the variable that will hold the returned transcription. For example, transcriptVarName.
  • Add a Snippet action that creates an object with a name matching the variable in transcriptVarName (out). The snippet must also convert the contents of this object to JSON. For example:

    DYNAMIC transcriptVarName
    ASSIGN nextPromptSequenceJSONout = "transcriptVarName.asJSON()"
  • Configure the nextPromptSequence property with the name of the variable that holds the JSON content. For example, nextPromptSequenceJSONout.
  • Set up your script to handle the transcribed content.

If you're using the transcribed content for another purpose, you don't need to include the Snippet or configure the nextPromptSequence. Your script must be configured to handle the transcribed content.

Code for VOICEBOT EXCHANGE

When a virtual agent sends a response to a contact's utteranceClosed What a contact says or types., the response is stored in the variable specified in the nextPromptSequenceVarName (out) field. The response is passed into the nextPromptSequence property as a series of prompt sequencesClosed A segment of an audio prompt played for the contact. that the script plays for the contact.

The contents of the variable used in the nextPromptSequenceVarName (out) field must be passed as JSON. You can convert the contents in the nextPromptSequence property or you can use a snippet in a Snippet action. Both approaches are acceptable. However, the benefit of creating a variable in a Snippet to hold the converted object is that it makes it easier to see where the conversion is happening. For example: 

DYNAMIC nextPromptSequence
ASSIGN nextPromptSequenceJSONout = "nextPromptSequence.asJSON()"

Use a Snippet

If you want to use a snippet, add a Snippet action to your script before Voicebot Exchange:

  1. Configure the nextPromptSequenceVarName (out) property with the name of the variable to hold the response from the virtual agent. For example, nextPromptSequence.
  2. Add the following lines to the Snippet action. The variables you use may be different.

    DYNAMIC nextPromptSequence
    ASSIGN nextPromptSequenceJSONout = "nextPromptSequence.asJSON()"
    
  3. Configure the nextPromptSequence property in the Voicebot Exchange action with the nextPromptSequenceJSONout variable.

Convert in the Property

If you convert the variable in the nextPromptSequence property, use the nextPromptSequenceVarName (out) variable with the asJSON() function. For example:

  • nextPromptSequenceVarName (out): nextPromptSequence.
  • nextPromptSequencenextPromptSequence.asJSON().