Prompts, messages, and other assistant properties can be dynamically set when starting a call based on templates. These templates are defined using double curly braces {{variableName}}. This is useful when you want to customize the assistant for a specific call.

For example, you could set the assistant’s first message to “Hello, {{name}}!” and then set name to John when starting the call by passing assistantOverrides with variableValues to the API or SDK:

{
  "variableValues": {
    "name": "John"
  }
}

Utilizing Dynamic Variables in Phone Calls

To leverage dynamic variables during phone calls, follow these steps:

  1. Prepare Your Request: Construct a JSON payload containing the following key-value pairs:

    • assistantId: Replace "your-assistant-id" with the actual ID of your assistant.
    • assistantOverride: This object is used to customize your assistant’s behavior.
      • variableValues: An object containing the dynamic variables you want to use, in the format { "variableName": "variableValue" }. For example, { "name": "John" }.
    • customer: An object representing the call recipient.
      • number: Replace "+1xxxxxxxxxx" with the phone number you wish to call (in E.164 format).
    • phoneNumberId: Replace "your-phone-id" with the ID of your registered phone number. You can get it from the Phone number in the dashboard.
  2. Send the Request: Dispatch the JSON payload to the /call/phone endpoint using your preferred method (e.g., HTTP POST request).

{
  "assistantId": "your-assistant-id",
  "assistantOverrides": {
    "variableValues": {
      "name": "John"
    }
  },
  "customer": {
    "number": "+1xxxxxxxxxx"
  },
  "phoneNumberId": "your-phone-id"
}

Default Variables

By default, the following variables are automatically filled based on the current (UTC) time, meaning that you don’t need to set them manually in variableValues:

VariableDescriptionExample
{{now}}Current date and time (UTC)Jan 1, 2024 12:00 PM
{{date}}Current date (UTC)Jan 1, 2024
{{time}}Current time (UTC)12:00 PM
{{month}}Current month (UTC)January
{{day}}Current day of month (UTC)1
{{year}}Current year (UTC)2024

Note: You will need to add the {{variableName}} in this format in all your prompts, whether it is the first message or anywhere else you want to use it.