Get started →
Documentation

TwiML overview

TwiML (Twilio Markup Language) is XML that tells Ruut Voice what to do on a call: speak, play audio, gather input, record, or dial. The root element is always <Response>.

How TwiML executes

When a call connects (outbound) or a number rings (inbound), Ruut Voice fetches TwiML — either from your server's URL or inline from the API — and executes each verb in order. Verbs like <Say> and <Play> run sequentially; <Gather> pauses for input; <Dial> transfers the call.

Structure

TwiMLxml



  

Return it correctly

Your server must return TwiML with Content-Type: text/xml (or application/xml). The SDK builds valid TwiML for you:

Examplets

import { VoiceResponse } from "@ruut/voice-sdk";

const xml = new VoiceResponse()
  .say("Hello world", { voice: "alice" })
  .toXml();
⚠️ Build on the VoiceResponse object. Calling .toXml() on a sub-builder (e.g. the return of dial()) drops the <Response> root and the platform rejects it.

The verbs

VerbPurposeReference
<Say>Speak text with text-to-speechsay
<Play>Play an audio fileplay
<Gather>Collect DTMF digits or speechgather
<Record>Record a message (optionally transcribe)record
<Dial>Transfer to a number, SIP, client, or conferencedial
<Pause>Wait for a number of secondspause
<Hangup>End the callhangup
<Redirect>Fetch new TwiML and continueredirect

Next

See the full TwiML verbs reference, or jump to a guide on receiving calls.