> This page is for SWML.

> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes.

# SWAIG

> The SignalWire AI Gateway Interface. Allows you to create user-defined functions that can be executed during the dialogue.

The SignalWire AI Gateway Interface. Allows you to create user-defined functions that can be executed during the dialogue.

> **Protect the SWML document**
>
> Webhook credentials set here, in a `web_hook_url` or in `web_hook_auth_password`, are part of the SWML
> document. Anyone who can fetch the document can read them. Serve it over HTTPS and verify that each
> request for it comes from SignalWire, as described in
> [Verify SWML request signatures](/docs/swml/guides/webhook-security).

A function that fails while the call runs, such as a webhook that errors, times out, or returns no
usable response, doesn't produce a [SWML error](/docs/swml/reference/errors) code and doesn't set
`script_error`. To trace function failures, use the `swaig_log` in the
[post-prompt report](/docs/swml/reference/calling/ai#post_prompt_url-callback) or the live
[debug webhook](/docs/swml/reference/calling/ai/params#debug_webhook_url-callback).

## **Properties**

**`ai.SWAIG`** `object`

An object that accepts the following properties.

---

**`SWAIG.defaults`** `object`

Default settings for all SWAIG functions. If `defaults` is not set, settings may be set in each function object. Default is not set.

---

**`defaults.web_hook_url`** `string`

The default URL to send status callbacks and reports to for all SWAIG functions. If `defaults` is not set, `web_hook_url` may be set in each [SWAIG function](/docs/swml/reference/calling/ai/swaig/functions) object. Authentication can also be set in the url in the format of `username:password@url`. Credentials embedded in the URL take precedence over `web_hook_auth_user` and `web_hook_auth_password`.

For what this URL receives and what it should return, see the
[tool webhook](/docs/swml/reference/calling/ai/swaig/functions#tool-webhook).

---

**`defaults.web_hook_auth_user`** `string`

The default username for basic auth on the function webhook, for functions that don't set their own `web_hook_auth_user`.

---

**`defaults.web_hook_auth_password`** `string`

The default password for basic auth on the function webhook, for functions that don't set their own `web_hook_auth_password`.

---

**`defaults.meta_data`** `object`

Metadata shared by every SWAIG function. A function's own [`meta_data`](/docs/swml/reference/calling/ai/swaig/functions) is merged over this, so a key set in both places takes the function's value.

---

**`defaults.meta_data_token`** `string`

The default scoping token for `meta_data`, for functions that don't set their own `meta_data_token`.

---

**`defaults.fillers_at_gates`** `boolean` — default: true

The default [`fillers_at_gates`](/docs/swml/reference/calling/ai/swaig/functions#functionsfillers_at_gates) for gated functions that don't set their own: whether a gated function's `fillers` play while its [semantic gates](/docs/swml/reference/calling/ai/swaig/functions/gates) are checked (`true`), or only after they pass (`false`).

---

**`SWAIG.functions`** `object[]`

An array of JSON objects to define functions that can be executed during the interaction with the AI. Default is not set. The fields of this object are the six following.

See [`functions`](/docs/swml/reference/calling/ai/swaig/functions) for additional details.

---

**`SWAIG.includes`** `object[]`

An array of objects to include remote function signatures. This allows you to include functions that are defined in a remote location.

See [`includes`](/docs/swml/reference/calling/ai/swaig/includes) for additional details.

---

**`SWAIG.internal_fillers`** `object`

An object that defines language-specific filler phrases for internal SWAIG functions.
These fillers help break silence between responses and are played asynchronously during function execution.
Each key is a function name, and each value is an object mapping [language codes](/docs/swml/reference/calling/ai/swaig#filler-language-codes) to arrays of filler phrases.

---

**`internal_fillers.check_time`** `object`

Filler phrases played when the AI Agent is checking the time. Used only when `check_time` is listed in [`SWAIG.native_functions`](#swaignative_functions).

---

**`internal_fillers.wait_for_user`** `object`

Filler phrases played when the AI Agent is waiting for user input. Used only when `wait_for_user` is listed in [`SWAIG.native_functions`](#swaignative_functions).

---

**`internal_fillers.wait_seconds`** `object`

Filler phrases played during deliberate pauses or wait periods. Used only when `wait_seconds` is listed in [`SWAIG.native_functions`](#swaignative_functions).

---

**`internal_fillers.adjust_response_latency`** `object`

Filler phrases played when the AI Agent is adjusting response timing. Used only when `adjust_response_latency` is listed in [`SWAIG.native_functions`](#swaignative_functions).

---

**`internal_fillers.next_step`** `object`

Filler phrases played when transitioning between conversation steps when utilizing [`prompt.contexts`](/docs/swml/reference/calling/ai/prompt).

---

**`internal_fillers.change_context`** `object`

Filler phrases played when switching between conversation contexts when utilizing [`prompt.contexts`](/docs/swml/reference/calling/ai/prompt).

---

**`internal_fillers.get_visual_input`** `object`

Filler phrases played when the AI Agent is processing visual input. Enabled when `enable_vision` is set to `true` in [`ai.params`](/docs/swml/reference/calling/ai/params).

Leaving this out does not silence the agent: a built-in English set is used under `en-US` instead, so set this key to change the wording or to cover another language.

---

**`internal_fillers.get_ideal_strategy`** `object`

Filler phrases played when the AI Agent is thinking or considering options. Enabled when `enable_thinking` is set to `true` in [`ai.params`](/docs/swml/reference/calling/ai/params).

Leaving this out does not silence the agent: a built-in English set is used under `en-US` instead, so set this key to change the wording or to cover another language.

---

**`internal_fillers.pause_conversation`** `object`

Filler phrases played when the AI Agent pauses the conversation at the caller's request. Enabled when `enable_pause` is set to `true` in [`ai.params`](/docs/swml/reference/calling/ai/params), which `start_paused` also turns on. Setting `speak_when_spoken_to` turns `enable_pause` back off, which leaves this key with nothing to play.

---

**`SWAIG.native_functions`** `string[]`

Prebuilt functions the AI agent is able to call.
The agent is already aware of these functions and can use them creatively based on prompting.
For example, a prompt like "tell the user what time it is" will automatically use `check_time`.

Accepted values:

* `adjust_response_latency` - Adjust how long the agent will wait for the user to stop talking.
* `check_time` - Returns the current time for the time zone set in [`ai.params.local_tz`](/docs/swml/reference/calling/ai/params#paramslocal_tz).
* `wait_for_user` - Causes the AI to wait until the user speaks again. Use when the user asks to wait or hold on.
* `wait_seconds` - Waits for the given amount of time.

---

**`SWAIG.mcp_servers`** `object[]`

An array of MCP (Model Context Protocol) servers whose tools and resources are made available to the AI. Each server's tools are discovered at startup and registered as callable functions, so they can be invoked like any other SWAIG function.

---

**`mcp_servers[].url`** `string` — required

The MCP server URL.

---

**`mcp_servers[].headers`** `object`

HTTP headers sent to the MCP server. Authorization tokens go here — there is no separate auth field. Header values are sent exactly as written; variables such as `${global_data.token}` are not expanded.

---

**`mcp_servers[].resources`** `boolean` — default: false

Whether to fetch the server's resources into `global_data`, when the server advertises resource support.

---

**`mcp_servers[].resource_vars`** `object`

Values for `{name}` placeholders in the URI templates of the server's resources. When a resource URI contains `{customer_id}`, the value of the `customer_id` key replaces it. Values are used exactly as written; variables such as `${global_data.customer_id}` are not expanded. A placeholder with no matching key is left as it is. Used only when `resources` is enabled.

---

### Filler language codes

Several SWAIG properties accept filler phrases keyed by language code, including [`internal_fillers`](#internal_fillers) and per-function [`fillers`](/docs/swml/reference/calling/ai/swaig/functions#fillers). Every one of them resolves the same way: the agent looks for an entry matching the language being spoken, then `auto`, then `default` (`auto` is skipped while the code is `multi`), and plays nothing when none of the three is set. A phrase is picked at random, never the same one twice in a row.

The codes below are the ones in common use, not a closed list. Under [`ai.multilingual`](/docs/swml/reference/calling/ai/multilingual) the key is whichever code the engine reports for the turn, so any code it returns works. Under [`ai.languages`](/docs/swml/reference/calling/ai/languages) the key has to match the `code` set on the entry.

| Code      | Description                                                                                                                                                                                   |
| :-------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `auto`    | Not a language: the phrases are translated into whichever language is being spoken. Takes precedence over `default`                                                                           |
| `default` | Not a language: the phrases play when no other entry matches the language being spoken                                                                                                        |
| `bg`      | Bulgarian                                                                                                                                                                                     |
| `ca`      | Catalan                                                                                                                                                                                       |
| `cs`      | Czech                                                                                                                                                                                         |
| `da`      | Danish                                                                                                                                                                                        |
| `da-DK`   | Danish (Denmark)                                                                                                                                                                              |
| `de`      | German                                                                                                                                                                                        |
| `de-CH`   | German (Switzerland)                                                                                                                                                                          |
| `el`      | Greek                                                                                                                                                                                         |
| `en`      | English                                                                                                                                                                                       |
| `en-AU`   | English (Australia)                                                                                                                                                                           |
| `en-GB`   | English (United Kingdom)                                                                                                                                                                      |
| `en-IN`   | English (India)                                                                                                                                                                               |
| `en-NZ`   | English (New Zealand)                                                                                                                                                                         |
| `en-US`   | English (United States)                                                                                                                                                                       |
| `es`      | Spanish                                                                                                                                                                                       |
| `es-419`  | Spanish (Latin America)                                                                                                                                                                       |
| `et`      | Estonian                                                                                                                                                                                      |
| `fi`      | Finnish                                                                                                                                                                                       |
| `fr`      | French                                                                                                                                                                                        |
| `fr-CA`   | French (Canada)                                                                                                                                                                               |
| `hi`      | Hindi                                                                                                                                                                                         |
| `hu`      | Hungarian                                                                                                                                                                                     |
| `id`      | Indonesian                                                                                                                                                                                    |
| `it`      | Italian                                                                                                                                                                                       |
| `ja`      | Japanese                                                                                                                                                                                      |
| `ko`      | Korean                                                                                                                                                                                        |
| `ko-KR`   | Korean (South Korea)                                                                                                                                                                          |
| `lt`      | Lithuanian                                                                                                                                                                                    |
| `lv`      | Latvian                                                                                                                                                                                       |
| `ms`      | Malay                                                                                                                                                                                         |
| `multi`   | Code-switching: the speech recognition engine detects and transcribes whichever of its supported languages the caller speaks, rather than one fixed language. `auto` is not used for this key |
| `nl`      | Dutch                                                                                                                                                                                         |
| `nl-BE`   | Flemish (Belgian Dutch)                                                                                                                                                                       |
| `no`      | Norwegian                                                                                                                                                                                     |
| `pl`      | Polish                                                                                                                                                                                        |
| `pt`      | Portuguese                                                                                                                                                                                    |
| `pt-BR`   | Portuguese (Brazil)                                                                                                                                                                           |
| `pt-PT`   | Portuguese (Portugal)                                                                                                                                                                         |
| `ro`      | Romanian                                                                                                                                                                                      |
| `ru`      | Russian                                                                                                                                                                                       |
| `sk`      | Slovak                                                                                                                                                                                        |
| `sv`      | Swedish                                                                                                                                                                                       |
| `sv-SE`   | Swedish (Sweden)                                                                                                                                                                              |
| `th`      | Thai                                                                                                                                                                                          |
| `th-TH`   | Thai (Thailand)                                                                                                                                                                               |
| `tr`      | Turkish                                                                                                                                                                                       |
| `uk`      | Ukrainian                                                                                                                                                                                     |
| `vi`      | Vietnamese                                                                                                                                                                                    |
| `zh`      | Chinese (Simplified)                                                                                                                                                                          |
| `zh-CN`   | Chinese (Simplified, China)                                                                                                                                                                   |
| `zh-Hans` | Chinese (Simplified Han)                                                                                                                                                                      |
| `zh-Hant` | Chinese (Traditional Han)                                                                                                                                                                     |
| `zh-HK`   | Chinese (Traditional, Hong Kong)                                                                                                                                                              |
| `zh-TW`   | Chinese (Traditional, Taiwan)                                                                                                                                                                 |

## **Examples**

### internal_fillers

#### YAML

```yaml
SWAIG:
  internal_fillers:
    change_context:
      en-US:
        - 'Let me switch gears.'
        - 'One moment.'
      es:
        - 'Voy a cambiar de tema.'
        - 'Un momento.'
    check_time:
      default:
        - 'Let me check the time.'
        - 'One moment while I get the time.'
        - 'Just checking the current time.'
```

#### JSON

```json
{
  "SWAIG": {
    "internal_fillers": {
      "change_context": {
        "en-US": [
          "Let me switch gears.",
          "One moment."
        ],
        "es": [
          "Voy a cambiar de tema.",
          "Un momento."
        ]
      },
      "check_time": {
        "default": [
          "Let me check the time.",
          "One moment while I get the time.",
          "Just checking the current time."
        ]
      }
    }
  }
}
```

### mcp_servers

#### YAML

```yaml
SWAIG:
  mcp_servers:
    - url: "https://crm.example.com/mcp"
      headers:
        Authorization: "Bearer YOUR_CRM_TOKEN"
      resources: true
      resource_vars:
        customer_id: "cust_12345"
```

#### JSON

```json
{
  "SWAIG": {
    "mcp_servers": [
      {
        "url": "https://crm.example.com/mcp",
        "headers": {
          "Authorization": "Bearer YOUR_CRM_TOKEN"
        },
        "resources": true,
        "resource_vars": {
          "customer_id": "cust_12345"
        }
      }
    ]
  }
}
```