Standard Context Variable Webhook

Connect connects Conversational AI Cloud with all of the services offered through the marketplace. It does this by providing a standardised webhook for the context variable webhook, and for transactional dialogs. This article explains the behaviour of the transactional dialog script, and how to use it.

Introduction

Conversational AI Cloud's context variable webhook allows customers to create a webhook to, for each interaction containing contextual answers, set the context for that particular interaction. This webhook allows for greater flexibility when defining the context for a particular interaction, as it allows customers to fetch data from sources external to the CM.com platform to determine context.

Behaviour

Connects standardised context variable webhook is a simple opinionated implementation that contains the follow logic:

  • Maps values set on the Conversational AI Cloud session (conversation variables) to identically named context variables
  • Makes conversation variables and context variables case insensitive when mapping

An example:

  • The customer has a context variable called "order_status", with 4 allowed values:
    • processing
    • cancelled
    • completed
  • The customer has a conversation variable called Order_Status that's dynamically set throughout the conversation
  • An event is triggered that contains:
    • A default answer, and;
    • 3 contextual answers, one for each of the order_status' allowed values

The context variable webhook is called with the following (partial) request body:

{
  "session": {
    "Order_Status": "Processing"
  },
  "contextVariables": [
    {
      "allowedValues": [
        "cancelled",
        "processing",
        "completed"
      ],
      "key": "order_status",
      "value": ""
    }
  ]
}

The webhook will (in order):

  • Map the values on the session (conversation variables) to the context variables in a case-insensitive way
  • Return the identically named conversation variable value if it is contained in the context variables allow values list

The response from the (partial) call in the above example would be:

{
  "order_status": "processing"
}