> This is a page from the ElevenLabs documentation. For a complete page index, fetch https://elevenlabs.io/docs/llms.txt. For the full documentation in a single file, fetch https://elevenlabs.io/docs/llms-full.txt.

# SMS-OTP-verificatie

![Agentgesprek waarin een telefoonnummer, OTP-code en succesvolle verificatie worden verzameld](/docs/_fern-img/97201c6fdad0c63900236b52726c867d3ff9405fdbd30725858f384653c95803.webp)

## Overzicht

Deze handleiding laat zien hoe je [Twilio Verify](https://www.twilio.com/docs/verify/api) met je ElevenLabs-agent integreert, zodat je een OTP naar het telefoonnummer van een beller kunt sturen en de code kunt verifiëren die deze tijdens een live spraakgesprek terugleest.

Je leert hoe je:

* Een Twilio Verify-service maakt en je gegevens Base64-codeert voor authenticatie.
* Twee webhook-tools (`send_SMS_verification` en `check_SMS_verification`) configureert in het [dashboard](https://elevenlabs.io/app/agents), met de [Agents CLI](/docs/nl/eleven-agents/operate/cli) of via de [ElevenLabs API](/docs/nl/api-reference/introduction).
* Beide webhook-calls authenticeert met een `Authorization`-header met een geheime waarde.
* De systeemtool [`skip_turn`](/docs/nl/eleven-agents/customization/tools/system-tools/skip-turn) inschakelt, zodat de agent wacht wanneer de beller de code nog niet heeft ontvangen.

## Vereisten

* Een Twilio-account met [Twilio Verify](https://www.twilio.com/docs/verify/api) ingeschakeld. Als Verify niet beschikbaar is in je Twilio Console, vraag dan toegang aan via [Twilio support](https://support.twilio.com/) of je Twilio-accountteam.
* Als je Twilio-account zich in de [proefmodus](https://www.twilio.com/docs/guides/how-to-use-your-free-trial-account) bevindt, moet het telefoonnummer van de ontvanger een geverifieerde caller ID in Twilio zijn.

#### Log in bij de Twilio Console

Open de [Twilio Console](https://console.twilio.com/).

#### Maak een Authenticate (Verify)-service

Kies in de linkerzijbalk **Add +** en maak een **Authenticate** (Verify)-service.

#### Geef de service een naam

Geef deze een duidelijke naam (bijvoorbeeld `ElevenLabs OTP`).

#### Kopieer de Verify Service SID

Open de pagina **Settings** van de service en kopieer de **Verify Service SID**. Deze begint met `VA` en verschilt van je Account SID.

> **Warning**
>
> **Veelgemaakte fout**: Gebruik je **Verify Service SID** (`VA...`) van de Authenticate (Verify)-service in de tool-URL's hieronder. Zet je **Account SID** (`AC...`) niet in het pad. De Verify API verwacht de service-SID in de URL; als je de Account SID gebruikt, krijg je `4xx`-fouten voor ongeldige parameters.

Je kunt de Twilio API Explorer in de console gebruiken om requests te testen voordat je ze aan je agent koppelt.

### Credentials coderen en webhooktools configureren

#### Codeer je Twilio-credentials voor Basic authentication

Twilio Verify gebruikt HTTP Basic authentication met je **Account SID** als gebruikersnaam en **Auth Token** als wachtwoord. Je vindt beide onder **Account Info** op de startpagina van de [Twilio Console](https://console.twilio.com/).

Codeer in je shell `ACCOUNT_SID:AUTH_TOKEN` met Base64 (gescheiden door een dubbele punt, zonder spaties):

```bash
printf '%s' 'YOUR_ACCOUNT_SID:YOUR_AUTH_TOKEN' | base64
```

Kopieer de uitvoer. De volledige waarde van de header `Authorization` bestaat uit het woord `Basic`, één spatie en die Base64-string. Sla deze in de volgende stappen op als tool secret.

```text
Basic dkFDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==
```

#### Configureer de tools \`send\_SMS\_verification\` en \`check\_SMS\_verification\`

`send_SMS_verification` roept Twilio Verify aan om een sms-OTP te verzenden. `check_SMS_verification` verstuurt de cijfers die de beller uitspreekt. Beide vereisen dezelfde Verify Service SID en hetzelfde `Authorization`-secret.

#### Toevoegen via het dashboard

### send\_SMS\_verification

![Agentgesprek waarin een telefoonnummer en OTP-code worden verzameld en de verificatie slaagt](/docs/_fern-img/9d72a753674c17481e99ea871b1b178cd7791f2da1ec3491ad4786c3fbc9a84e.webp)

Kies in het gedeelte **Agent** van je agentinstellingen **Add Tool** en selecteer **Webhook**.

| Veld         | Waarde                                                                        |
| ------------ | ----------------------------------------------------------------------------- |
| Naam         | `send_SMS_verification`                                                       |
| Beschrijving | Verstuurt via sms een OTP-verificatiecode naar het opgegeven telefoonnummer   |
| Methode      | `POST`                                                                        |
| URL          | `https://verify.twilio.com/v2/Services/YOUR_VERIFY_SERVICE_SID/Verifications` |

Vervang `YOUR_VERIFY_SERVICE_SID` door de `VA...`-SID uit de eerste stap.

**Authentication header:** Voeg onder **Headers** `Authorization` toe als type **Secret** en plak de volledige waarde (`Basic ` plus Base64). Zie [Webhooktools](/docs/nl/eleven-agents/customization/tools/webhook-tools).

**Body parameters:** Stel **Content type** in op **URL-encoded** (`application/x-www-form-urlencoded`). Voeg parameters toe met **LLM Prompt** als waardetype:

| Gegevenstype | ID        | Beschrijving                                                                 |
| ------------ | --------- | ---------------------------------------------------------------------------- |
| `string`     | `To`      | Telefoonnummer van de beller in E.164-indeling (bijvoorbeeld `+14155552671`) |
| `string`     | `Channel` | Bezorgkanaal; gebruik `sms`                                                  |

### check\_SMS\_verification

Voeg een tweede webhooktool toe:

| Veld         | Waarde                                                                            |
| ------------ | --------------------------------------------------------------------------------- |
| Naam         | `check_SMS_verification`                                                          |
| Beschrijving | Controleert of de door de beller opgegeven OTP-code geldig is                     |
| Methode      | `POST`                                                                            |
| URL          | `https://verify.twilio.com/v2/Services/YOUR_VERIFY_SERVICE_SID/VerificationCheck` |

Gebruik dezelfde Verify Service SID en hetzelfde `Authorization`-secret als voor `send_SMS_verification`.

**Body parameters:** **URL-encoded**. Voeg `To` (E.164) en `Code` (OTP-cijfers) toe met **LLM Prompt**.

#### Toevoegen via de CLI

> **Note**
>
> Maak een [workspace secret](/docs/nl/api-reference/workspace/secrets/create) waarvan de waarde de volledige `Authorization`-header is (`Basic ` plus Base64). Zet de secret-ID in de JSON hieronder als `YOUR_SECRET_ID`.

#### Configuratiebestanden voor tools toevoegen

Sla de verzendtool op als `tool_configs/send_SMS_verification.json` (vervang `YOUR_VERIFY_SERVICE_SID` door je `VA...`-SID):

```json
{
  "type": "webhook",
  "name": "send_SMS_verification",
  "description": "Sends an OTP verification code via SMS to the provided phone number",
  "api_schema": {
    "url": "https://verify.twilio.com/v2/Services/YOUR_VERIFY_SERVICE_SID/Verifications",
    "method": "POST",
    "content_type": "application/x-www-form-urlencoded",
    "request_headers": {
      "Authorization": { "secret_id": "YOUR_SECRET_ID" }
    },
    "request_body_schema": {
      "type": "object",
      "description": "Twilio Verify start verification parameters",
      "required": ["To", "Channel"],
      "properties": {
        "To": {
          "type": "string",
          "description": "Caller phone number in E.164 format (for example +14155552671)"
        },
        "Channel": {
          "type": "string",
          "constant_value": "sms"
        }
      }
    }
  }
}
```

Sla de controledool op als `tool_configs/check_SMS_verification.json`:

```json
{
  "type": "webhook",
  "name": "check_SMS_verification",
  "description": "Checks whether the OTP code provided by the caller is valid",
  "api_schema": {
    "url": "https://verify.twilio.com/v2/Services/YOUR_VERIFY_SERVICE_SID/VerificationCheck",
    "method": "POST",
    "content_type": "application/x-www-form-urlencoded",
    "request_headers": {
      "Authorization": { "secret_id": "YOUR_SECRET_ID" }
    },
    "request_body_schema": {
      "type": "object",
      "description": "Twilio Verify verification check parameters",
      "required": ["To", "Code"],
      "properties": {
        "To": {
          "type": "string",
          "description": "Same caller number in E.164 format"
        },
        "Code": {
          "type": "string",
          "description": "The OTP digits the caller provided"
        }
      }
    }
  }
}
```

#### Registreer de tools

```bash
elevenlabs tools add "send_SMS_verification" --type "webhook" --config-path ./tool_configs/send_SMS_verification.json
elevenlabs tools add "check_SMS_verification" --type "webhook" --config-path ./tool_configs/check_SMS_verification.json
```

#### Koppel de tools aan je agent

Bewerk `agent_configs/<agent-name>.json`. Stel onder `conversation_config.agent.prompt` `tool_ids` zo in dat beide tools zijn opgenomen (gebruik de ID's uit `tools.json` of uit `elevenlabs agents tools list`). Push vervolgens:

```bash
elevenlabs agents push --agent "<agent-name>"
```

#### Toevoegen via de API

> **Note**
>
> Maak een [workspace secret](/docs/nl/api-reference/workspace/secrets/create) met de volledige headerwaarde `Basic ...` en geef de ID vervolgens door als `secret_id` in `request_headers`.

```python
from elevenlabs import ElevenLabs, ToolRequestModel

elevenlabs = ElevenLabs()

send_sms = elevenlabs.conversational_ai.tools.create(
    request=ToolRequestModel(
        tool_config={
            "type": "webhook",
            "name": "send_SMS_verification",
            "description": "Sends an OTP verification code via SMS to the provided phone number",
            "api_schema": {
                "url": "https://verify.twilio.com/v2/Services/YOUR_VERIFY_SERVICE_SID/Verifications",
                "method": "POST",
                "content_type": "application/x-www-form-urlencoded",
                "request_headers": {
                    "Authorization": {"secret_id": "YOUR_SECRET_ID"},
                },
                "request_body_schema": {
                    "type": "object",
                    "description": "Twilio Verify start verification parameters",
                    "required": ["To", "Channel"],
                    "properties": {
                        "To": {
                            "type": "string",
                            "description": "Caller phone number in E.164 format (for example +14155552671)",
                        },
                        "Channel": {
                            "type": "string",
                            "constant_value": "sms",
                        },
                    },
                },
            },
        }
    )
)

check_sms = elevenlabs.conversational_ai.tools.create(
    request=ToolRequestModel(
        tool_config={
            "type": "webhook",
            "name": "check_SMS_verification",
            "description": "Checks whether the OTP code provided by the caller is valid",
            "api_schema": {
                "url": "https://verify.twilio.com/v2/Services/YOUR_VERIFY_SERVICE_SID/VerificationCheck",
                "method": "POST",
                "content_type": "application/x-www-form-urlencoded",
                "request_headers": {
                    "Authorization": {"secret_id": "YOUR_SECRET_ID"},
                },
                "request_body_schema": {
                    "type": "object",
                    "description": "Twilio Verify verification check parameters",
                    "required": ["To", "Code"],
                    "properties": {
                        "To": {
                            "type": "string",
                            "description": "Same caller number in E.164 format",
                        },
                        "Code": {
                            "type": "string",
                            "description": "The OTP digits the caller provided",
                        },
                    },
                },
            },
        }
    )
)

elevenlabs.conversational_ai.agents.update(
    agent_id="agent_7101k5zvyjhmfg983brhmhkd98n6",
    conversation_config={
        "agent": {
            "prompt": {
                "tool_ids": [send_sms.id, check_sms.id],
            },
        },
    },
)
```

```typescript
import { ElevenLabsClient } from "@elevenlabs/elevenlabs-js";

const elevenlabs = new ElevenLabsClient();

const sendSms = await elevenlabs.conversationalAi.tools.create({
  toolConfig: {
    type: "webhook",
    name: "send_SMS_verification",
    description: "Sends an OTP verification code via SMS to the provided phone number",
    apiSchema: {
      url: "https://verify.twilio.com/v2/Services/YOUR_VERIFY_SERVICE_SID/Verifications",
      method: "POST",
      contentType: "application/x-www-form-urlencoded",
      requestHeaders: {
        Authorization: { secretId: "YOUR_SECRET_ID" },
      },
      requestBodySchema: {
        type: "object",
        description: "Twilio Verify start verification parameters",
        required: ["To", "Channel"],
        properties: {
          To: {
            type: "string",
            description: "Caller phone number in E.164 format (for example +14155552671)",
          },
          Channel: {
            type: "string",
            constantValue: "sms",
          },
        },
      },
    },
  },
});

const checkSms = await elevenlabs.conversationalAi.tools.create({
  toolConfig: {
    type: "webhook",
    name: "check_SMS_verification",
    description: "Checks whether the OTP code provided by the caller is valid",
    apiSchema: {
      url: "https://verify.twilio.com/v2/Services/YOUR_VERIFY_SERVICE_SID/VerificationCheck",
      method: "POST",
      contentType: "application/x-www-form-urlencoded",
      requestHeaders: {
        Authorization: { secretId: "YOUR_SECRET_ID" },
      },
      requestBodySchema: {
        type: "object",
        description: "Twilio Verify verification check parameters",
        required: ["To", "Code"],
        properties: {
          To: {
            type: "string",
            description: "Same caller number in E.164 format",
          },
          Code: {
            type: "string",
            description: "The OTP digits the caller provided",
          },
        },
      },
    },
  },
});

await elevenlabs.conversationalAi.agents.update("agent_7101k5zvyjhmfg983brhmhkd98n6", {
  conversationConfig: {
    agent: {
      prompt: {
        toolIds: [sendSms.id, checkSms.id],
      },
    },
  },
});
```

> **Note**
>
> Als je **`Channel`** in het dashboard als een door de LLM ingevuld veld configureert, voeg dan instructies toe aan je system prompt zodat het model altijd `sms` doorgeeft. In de bovenstaande CLI- en API-voorbeelden wordt `sms` vastgezet met `constant_value` / `constantValue`, zodat het model het kanaal niet kiest.

#### Schakel de system tool \`skip\_turn\` in

Bellers hebben vaak even tijd nodig om de sms te ontvangen voordat ze de code kunnen voorlezen. Zonder `skip_turn` kan de agent door de stilte heen praten of prompts herhalen.

#### Toevoegen via het dashboard

Kies in **Tools** **Add Tool**, selecteer **System tool** en schakel **Skip turn** in. Verdere configuratie is niet nodig.

#### Toevoegen via de CLI

Stel in `agent_configs/<agent-name>.json`, onder `conversation_config.agent.prompt`, `built_in_tools.skip_turn` in op `null` (standaardinstellingen) zodat Skip turn is ingeschakeld. Voer vervolgens uit:

```bash
elevenlabs agents push --agent "<agent-name>"
```

#### Toevoegen via de API

```python
from elevenlabs import ElevenLabs

elevenlabs = ElevenLabs()

elevenlabs.conversational_ai.agents.update(
    agent_id="agent_7101k5zvyjhmfg983brhmhkd98n6",
    conversation_config={
        "agent": {
            "prompt": {
                "built_in_tools": {
                    "skip_turn": None,
                },
            },
        },
    },
)
```

```typescript
import { ElevenLabsClient } from "@elevenlabs/elevenlabs-js";

const elevenlabs = new ElevenLabsClient();

await elevenlabs.conversationalAi.agents.update("agent_7101k5zvyjhmfg983brhmhkd98n6", {
  conversationConfig: {
    agent: {
      prompt: {
        builtInTools: {
          skipTurn: null,
        },
      },
    },
  },
});
```

Als je `tool_ids` al hebt ingesteld bij het maken van de webhooktools, voeg `built_in_tools` dan samen in hetzelfde `prompt`-object in plaats van dit te vervangen.

Voeg richtlijnen toe aan de system prompt zodat het model weet wanneer het deze moet aanroepen, bijvoorbeeld:

```text
When the caller indicates they are still waiting to receive the OTP code — for example,
"hold on", "I haven't received it yet", or "give me a second" — use the skip_turn tool
to wait silently rather than speaking. Do not repeat the prompt or ask for the code again
until the caller indicates they are ready.
```

Zie [Skip turn](/docs/nl/eleven-agents/customization/tools/system-tools/skip-turn) voor meer informatie.

#### Orkestreer de flow in de system prompt

Gebruik een system prompt waarin de volgorde van de tools duidelijk is, bijvoorbeeld:

```text
You are a secure verification agent. When you need to verify a caller's identity:

1. Ask for their phone number if you do not already have it.
2. Standardize the number to E.164 for tool calls: a leading plus, country code, then digits only, no spaces (for example +14155552671).
3. Call send_SMS_verification with their number and Channel set to "sms".
4. Tell the caller: "I've sent a verification code to your phone. Please read it out when you're ready."
5. If the caller says they haven't received the code yet or asks for a moment, use skip_turn to wait silently.
6. Once the caller provides the code, call check_SMS_verification with their number and the code.
7. If the response status is "approved", proceed with the verified flow.
8. If the code is invalid, let the caller know and offer to resend.
```

## Problemen oplossen

### Twilio `60200` — Ongeldige parameter (HTTP 400)

Twilio kan een body zoals deze retourneren wanneer de request-URL of body niet overeenkomt met wat de Verify API verwacht:

```json
{
  "code": 60200,
  "message": "Invalid parameter",
  "more_info": "https://www.twilio.com/docs/errors/60200",
  "status": 400
}
```

**Wat je moet controleren:** Het pad moet je **Verify Service SID** (`VA...`) uit de instellingen van de Authenticate (Verify)-service gebruiken. Je **Account SID** (`AC...`) in `.../Services/{Sid}/...` zetten is een veelvoorkomende oorzaak van `60200`. Bekijk de Twilio-documentatie over [60200](https://www.twilio.com/docs/errors/60200) voor andere gevallen van ongeldige parameters.

### Twilio `20003` — Authentication Error — No credentials provided (HTTP 401)

Wanneer de header `Authorization` ontbreekt, onjuist is opgebouwd of niet wordt verzonden, kan Twilio reageren met:

```json
{
  "code": 20003,
  "message": "Authentication Error - No credentials provided",
  "more_info": "https://www.twilio.com/docs/errors/20003",
  "status": 401
}
```

**Wat je moet controleren:** De tool moet een `Authorization`-header versturen waarvan de waarde de volledige tekenreeks `Basic <base64>` is (inclusief het woord `Basic` en één spatie vóór de Base64-uitvoer). De Base64-invoer moet exact `ACCOUNT_SID:AUTH_TOKEN` zijn, zonder extra spaties of regeleinden. Controleer of het secret aan deze header is gekoppeld voor beide webhooktools. Zie [20003](https://www.twilio.com/docs/errors/20003).

### Andere problemen

* **Nummer afgewezen in de proefmodus:** Open in de Twilio Console [Verified phone numbers](https://console.twilio.com/us1/develop/phone-numbers/manage/verified) en controleer voordat je test of het nummer van de ontvanger in de lijst staat.
* **Agent praat door de beller heen:** Controleer of **Skip turn** is ingeschakeld en of de system prompt het model vertelt `skip_turn` te gebruiken wanneer de beller tijd nodig heeft.