---
"@context": https://schema.org
"@type": TechArticle
"@id": https://www.twilio.com/docs/voice/conversationrelay/turn-detection#article
headline: Turn Detection for Conversation Relay
description: Use Turn Detection with Conversation Relay to tell when a caller has finished speaking, so your AI voice agent doesn't interrupt callers who pause.
url: https://www.twilio.com/docs/voice/conversationrelay/turn-detection
inLanguage: en
dateModified: 2026-11-18T23:00:17.000Z
author:
  "@type": Organization
  name: Twilio Developer Education Team
publisher:
  "@type": Organization
  name: Twilio
---

# Turn Detection for Conversation Relay

> \[!NOTE]
>
> Turn Detection uses artificial intelligence or machine learning technologies. By enabling or using any features or functionalities within Programmable Voice that Twilio identifies as using artificial intelligence or machine learning technology, you acknowledge and agree to certain terms. Your use of these features or functionalities is subject to the terms of the [Predictive and Generative AI or ML Features Addendum](https://www.twilio.com/en-us/legal/ai-terms/predictive-generative-ai-features).
>
> Turn Detection isn't PCI compliant or a HIPAA Eligible Service. Don't use the [`turnDetection`](/docs/voice/twiml/connect/conversationrelay#conversationrelay-attributes) attribute in workflows that are subject to PCI or HIPAA regulations.

Learn how to use Turn Detection with Conversation Relay to detect when a caller has finished speaking. Turn Detection lets your AI voice agent wait while a caller pauses to think, and then respond promptly after the caller finishes.

To learn more about the `<ConversationRelay>` attributes and WebSocket messages that this guide uses, see [Related reference documentation](#related-reference-documentation).

For other guides, see [All Conversation Relay guides](/docs/voice/guides/by-feature-product#conversation-relay).

## How Turn Detection works

An AI voice agent needs to know when the caller has finished speaking. If the agent responds too early, it interrupts the caller. If it waits too long, the conversation feels slow.

By default, Conversation Relay relies on the speech-to-text (STT) provider's silence detection to end the caller's turn. A silence threshold can't distinguish between a caller who has finished speaking and a caller who is pausing to think or using filler words. As a result, the agent sometimes interrupts the caller.

Turn Detection replaces the silence-based decision with a semantics-aware machine learning model built by Twilio. The model evaluates the caller's audio, not the transcript. It does this in real time to determine whether the caller has completed their turn or is pausing mid-sentence. The model runs in Twilio's media stack alongside STT, so it works with all supported STT providers and speech models except Deepgram Flux. For more information about Flux, see [Limitations](#limitations).

When the model determines that the turn is complete, Conversation Relay sends the `prompt` message with `last` set to `true`, instead of waiting for an STT silence timer to expire. Turn Detection affects only when the turn ends. Turn Detection doesn't change how Conversation Relay detects interruptions of the agent's speech.

## When to use Turn Detection

Turn Detection is most useful when callers often pause in the middle of a thought. Consider the following scenarios:

* **Long values**: Callers who recite confirmation codes, tracking numbers, or phone numbers tend to pause between groups of digits.
* **Hesitant conversations**: In technical support or claims calls, callers often stop to collect their thoughts or use filler words such as *um* and *ah*.
* **Bookings and reservations**: A caller might say "I'd like a table for" and pause before adding "four people on Friday night." An agent that replies after the first pause interrupts the caller.

## Turn on Turn Detection

To turn on Turn Detection, set the `turnDetection` attribute to `true` on the `<ConversationRelay>` noun:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Connect>
    <ConversationRelay
      url="wss://YOUR_SERVER_URL"
      welcomeGreeting="Hi! How can I help you today?"
      turnDetection="true"
    />
  </Connect>
</Response>
```

Replace `YOUR_SERVER_URL` with the URL of your WebSocket server.

You don't need to change your WebSocket server. Your application continues to receive [`prompt` messages](/docs/voice/conversationrelay/websocket-messages#prompt-message) and treats `last: true` as the end of the caller's turn. A `prompt` message that ends the caller's turn looks like the following:

```json
{
  "type": "prompt",
  "voicePrompt": "I would like to book a table for Friday night.",
  "lang": "en-US",
  "last": true
}
```

## Receive turn state

If your application needs more detail about the caller's turn, set the `includeInPrompt` attribute to `turn-state`. Conversation Relay then adds a `turnState` field to the `prompt` messages that it sends. To receive the `start` and `interim` turn states, also set `partialPrompts` to `true`.

```xml
<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Connect>
    <ConversationRelay
      url="wss://YOUR_SERVER_URL"
      turnDetection="true"
      includeInPrompt="turn-state"
      partialPrompts="true"
    />
  </Connect>
</Response>
```

With this configuration, the `prompt` message that ends the caller's turn is similar to the following:

```json
{
  "type": "prompt",
  "voicePrompt": "I would like to book a table for Friday night.",
  "lang": "en-US",
  "last": true,
  "turnState": "end"
}
```

The `turnState` field can have one of the following values: `start`, `interim`, or `end`. To learn what each value means and when Conversation Relay sends it, see the [`prompt` message with turn state](/docs/voice/conversationrelay/websocket-messages#prompt-message-with-turn-state) reference.

## Tune when a turn ends

Use the following attributes to balance how quickly Conversation Relay reports the end of a turn against how accurately it reports it:

| Attribute        | Description                                                                                                                                                                                | Default                                         | Allowed values                                          |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------- | ------------------------------------------------------- |
| `turnMinSilence` | The minimum silence that Conversation Relay waits for before it reports the end of a turn. Conversation Relay doesn't end the turn until the caller has been quiet for at least this long. | `300` milliseconds                              | An integer from `100` to `2000` milliseconds            |
| `speechTimeout`  | The time after which Conversation Relay reports the end of a turn when the model isn't certain that the caller has finished speaking.                                                      | `2000` milliseconds (`3000` with Deepgram Flux) | `auto`, or an integer from `600` to `5000` milliseconds |
| `eotThreshold`   | How confident the model must be that the caller has finished speaking before Conversation Relay ends the turn.                                                                             | `0.8`                                           | `0.5` to `0.9`                                          |

Set `speechTimeout` to at least `300` milliseconds more than `turnMinSilence`. `turnMinSilence` doesn't apply with Deepgram Flux.

With the default values, `turnMinSilence="300"` and `speechTimeout="2000"`, Conversation Relay favors a faster response. It might split a single caller turn into more than one prompt report. To tune the balance, start by adjusting `turnMinSilence`:

* **Longer turns**: Increase `turnMinSilence` if callers pause often and Conversation Relay ends their turns too early.
* **Faster responses**: Decrease `turnMinSilence` to reduce the delay before Conversation Relay reports the end of a turn.

Test `eotThreshold` together with `turnMinSilence`. A higher `eotThreshold` makes Conversation Relay less sensitive to low-confidence turn decisions, which results in longer turns and fewer splits.

## Change Turn Detection settings during a call

You can change the `turnDetection`, `includeInPrompt`, `turnMinSilence`, `speechTimeout`, `eotThreshold`, and `partialPrompts` settings during a call by sending a `config` message over your WebSocket connection. For example, you can turn on Turn Detection for the part of the call where the caller recites a long number, and then turn it off afterward. The following message turns on Turn Detection and sets `speechTimeout` to `2000` milliseconds:

```json
{
  "type": "config",
  "session": {
    "turnDetection": true,
    "speechTimeout": 2000
  }
}
```

A change to `includeInPrompt` or `partialPrompts` takes effect immediately. A change to `turnDetection`, `turnMinSilence`, `speechTimeout`, or `eotThreshold` takes effect at the end of the caller's current turn, so send the update before the caller starts answering. If a `config` message has a value that is out of range, or leaves less than `300` milliseconds between `turnMinSilence` and `speechTimeout`, Conversation Relay rejects it and sends an error message over your WebSocket connection. The call continues with its current settings. For timing details and the full list of settings that you can update, see [Update configuration during a call](/docs/voice/conversationrelay/dynamic-configuration).

## Limitations

Turn Detection works with all supported STT providers and speech models except Deepgram Flux, which has its own turn detection model built in. If you set `turnDetection` to `true` and also set `transcriptionProvider` to `Deepgram` and `speechModel` to `flux`, Conversation Relay bypasses Twilio Turn Detection and uses the Flux turn detection model. You can still use `includeInPrompt="turn-state"` with Flux. To tune Flux turn detection, use the `eotThreshold` and `speechTimeout` attributes. For more information about these attributes, see the [`<ConversationRelay>` reference](/docs/voice/twiml/connect/conversationrelay#conversationrelay-attributes).

## Next steps

Explore the following guides to build on what you've learned:

* [Best practices for Conversation Relay](/docs/voice/conversationrelay/best-practices): Learn how to handle caller silence, prevent false interruptions, and stream text tokens.
* [Update configuration during a call](/docs/voice/conversationrelay/dynamic-configuration): Change language, voice, and session settings over your WebSocket connection without ending the call.

## Related reference documentation

Find reference documentation for the topics on this page.

* [TwiML™ Voice: `<ConversationRelay>`](/docs/voice/twiml/connect/conversationrelay): Reference documentation for the `turnDetection`, `includeInPrompt`, `turnMinSilence`, and `speechTimeout` attributes.
* [Getting and sending WebSocket messages](/docs/voice/conversationrelay/websocket-messages): Reference documentation for the `prompt` message and its `turnState` field.
