Context

The NLX Context API is a specialized endpoint that asynchronously sets session attributes for an active NLX conversation, with special capabilities for Voice+.

Unlike the Track API (which tracks journey steps), the Context API allows you to push detailed metadata about the current page—such as available form fields, current values, and navigation URLs—so the Voice AI knows exactly what the user is looking at.

When to use this API

  • Form Filling: Tell the Voice AI what fields are on the screen (e.g., "Account Number", "Amount") so it can offer to fill them.

  • Navigation Awareness: Update the Voice AI when the user navigates to a new URL.

  • State Synchronization: Send current field values to the Voice+ app if the user manually types them in.

  • Context Updates: Update the context of your conversation asynchronously.

Configuration

This endpoint is part of the standard Conversation API suite and shares the same authentication.

Setting

Value

Base URL

https://apps.nlx.ai/c/{deploymentKey}/{channelKey}-{languageCode}/context

Header

nlx-api-key: YOUR_API_KEY

Important: Ensure you append /context to the standard base URL.

Send Context (POST)

Push a context payload to the active conversation.

Endpoint: POST /context

Request Body

Field

Type

Required

Description

conversationId

String

Yes

The active voice session ID.

context

Object

Yes

Wrapper for context data.

context.nlx:vpContext

Object

Yes

The specific Voice+ context container.

Example: Form Fields

In this example, the web app tells the Voice AI that the user is on a "Transfer" page with fields for Account and Amount.

curl -X POST "https://apps.nlx.ai/c/xxxx/xxxx-en-US/context" \
  -H "nlx-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "conversationId": "c03e0066-7cba-4bbf-b60b-10109b95a9f6",
    "context": {
      "nlx:vpContext": {
        "uri": "https://mybank.com/transfer",
        "fields": [
          {
            "id": "toAccount",
            "name": "To Account",
            "type": "select",
            "description": "Destination account",
            "value": "1131"
          },
          {
            "id": "amount",
            "name": "Transfer Amount",
            "type": "number",
            "description": "Amount in USD",
            "placeholder": "Enter amount"
          }
        ]
      }
    }
  }'

Response

The server responds with a 200 OK empty JSON object upon success.

{}

Last updated