Context

Utilizing Context Variables for Dynamic Dialog Management

Context variables cover a broad range of conversational parameters beyond single interactions. Parloa currently supports the following context variables:

KeyTypeDescription

context.accessToken

string

The user's access token is only provided for requests made by users who have linked their account with your project.

context.accountIsLinked

boolean

Indicates whether the current user has successfully performed account linking in the past, but does not ensure that the user's account is still linked. If a user revokes the permission in their linked account, the placeholder will still resolve to true because the system has no way of knowing that the permission was revoked in a third-party system.

context.isNewConversation

boolean

Indicates whether a new conversation is starting with the current request.

context.lastInteraction

date

The date of the last interaction between a user and your project.

Note: This value is null during the first interaction.

context.lastServiceCallError

string

In the event of a failed service call, the error message that is returned can be:

  • HTTP_ERROR: The received response code is not in the range 200-300.

  • ECONNREFUSED: No connection could be made because the target machine actively refused it.

  • ECONNRESET: A connection was forcibly closed by a peer.

  • ECONNABORTED: Service timeout

  • ENOTFOUND: Indicates a DNS failure.

  • ETIMEDOUT: A connect or send request failed because the connected party did not properly respond.

  • EPIPE: A write on a pipe, socket, or FIFO for which there is no process to read the data.

  • ECONNABORTED: The network connection has been aborted.

  • UNKNOWN: Anything else went wrong.

context.lastServiceCallStatus

number

The HTTP Status code received from a Service in the last service request performed. If the last service call returned an error, this variable will be undefined.

context.locale

string

Contains the language code of the release in BCP 47 format, such as de-DE or en-GB.

context.platform

string

The platform is currently being used. Possible values:

  • phoneV1

  • phoneV2

  • gaction

context.previousPrompt

string

The SSML prompt sent with the last response.

context.previousPromptText

string

The prompt displayText sent with the last response.

context.previousReprompt

string

The SSML prompt sent with the last response.

context.previousRepromptText

string

The prompt displayText sent with the last response.

context.reasonLastConversationEnded

string

The reason why the last conversation ended. Possible values are:

  • PARLOA_INITIATED

  • USER_INITIATED

  • NO_INPUT

  • ERROR

  • UNKNOWN

context.requestCount

number

Track of the number of back-and-forth interactions a user has had per release. The count starts at 1 for the initial interaction and increases with each subsequent exchange. It resets with different releases, only measuring the turn count for the current release. On the other hand, context.sessionCount counts the total calls a user has made to this release.

context.requestCountInSession

number

Tracks the number of conversation turns in the current session. A turn consists of a user input and a bot response. For example, a phone call initiated by the user and the bot's greeting count as one turn. The count starts at 1 and increments with each turn. It resets to 1 with each new phone call.

context.requestScopedRandomValue

number

A random float value in the range [0-1] is constant during a request but changes on each new request.

context.sessionCount

number

The number of conversations a user has had with a specific release, starting at 1 for the first conversation and incrementing with each new conversation. Different versions within the same release do not reset this counter, but different releases will have separate counts, essentially tracking the user's phone call count per release.

context.textblockUsages

string, number

This object contains the usage count for each text snippet. It can be accessed as follows: context.textblockUsages.<textsnippetName>

Key Features of Context Variables

  • They enable dynamic responses based on the conversation history.

  • Context variables can be used to repeat or reference previous interactions.

  • Some context variables are specifically intended for use within JavaScript fields to allow for advanced scripting and customization of the dialog flow.

Interaction with Context Variables

In the non-JavaScript fields of Parloa's platform, you might encounter a limited set of context variables available via the autocomplete feature. This is due to certain variables being designed exclusively for JavaScript contexts where more complex logic can be applied.

It's crucial not to confuse these context-specific variables with those used for service calls, which are designed for external interactions, such as API requests.

Example of Context Variable Usage

The example provided showcases the use of context.previousPrompt and context.previousPromptText within a dialogue block. These particular variables enable the system to repeat the last prompt heard by the user. This functionality is invaluable when the user has not understood or responded appropriately, requiring the system to reiterate the previous message.

  • The context.previousPrompt variable will repeat the last SSML (Speech Synthesis Markup Language) content, which might include specific intonation or speech pacing instructions.

  • The context.previousPromptText variable repeats the plain text version of the last message, which is useful for text-based platforms or debugging purposes.

Last updated