Input Variables allow you to provide contextual information to GenerativeAgent when analyzing a conversation. This is the main way to pass information from your application to GenerativeAgent. These variables can then be referenced in the task instructions and functions.

Use Input Variables provide GenerativeAgent with context information like:

  • Entities extracted from a previous system or API call
  • Relevant customer metadata
  • Conversation context, like a summary of previous interactions
  • Instructions on the next steps for a given task

Add Input Variables to a conversation

To add input variables to a conversation, you needs to:

1

Add Input Variables with /analyze

Call analyze, adding the inputVariables attributes. inputVariables is an untyped JSON object and you can pass any key-value pairs. You need to ensure you are consistent in the key names you use between /analyze and the task instructions.

With each call, any new input variable is added to the conversation context.

curl --request POST \
  --url https://api.sandbox.asapp.com/generativeagent/v1/analyze \
  --header 'Content-Type: application/json' \
  --header 'asapp-api-id: <api-key>' \
  --header 'asapp-api-secret: <api-key>' \
  --data '{
  "conversationId": "01BX5ZZKBKACTAV9WEVGEMMVS0",
  "message": {
    "text": "Hello, I would like to upgrade my internet plan to GOLD.",
    "sender": {
      "role": "agent",
      "externalId": 123
    },
    "timestamp": "2021-11-23T12:13:14.555Z"
  },
  "taskName": "UpgradePlan",
  "inputVariables": {
    "context": "Customer called to upgrade their current plan to GOLD",
    "customer_info": {
      "current_plan": "SILVER",
      "customer_since": "2020-01-01"
    }
  }
}'
2

Reference Input Variables in Task Instructions

Once the Input Variables are added to the conversation, they are made part of GenerativeAgents’ Context. GenerativeAgent will consider them when interacting with your users.

You can also reference them directly in the task instructions.

The customer has a plan status of {{ input_vars.get("customer_info.current_plan") }}

Input variables can be used as part of Conditional Templates.

Add Input Variables in the Previewer

While you are iterating on your tasks, you simulate how GenerativeAgent responds with added Input Variables in the Previewer

You can also simulate directly launching the customer into a specific task, instead of allowing GenerativeAgent to choose a task.

In a scenario where a IVR has already gathered information, you can ensure GenerativeAgent picks up from where the IVR left off.

Was this page helpful?