Skip to main content
Twilio carries the calls and texts. The engine decides what happens on them: who is open, which department a caller reaches, who rings, and what is kept afterwards. Twilio posts every event on a call or a text to the engine’s phone function, and every post is checked against Twilio’s signature before anything is read.

Who owns what

A department’s ring length, wait limit and whether it is always open are settings on the department; the closed switch, the callback offer interval and the voicemail length are phone settings. The phone reads all of them fresh every 30 seconds, so a change is live within half a minute. How to change them is on Change opening hours and holidays.

How a call is routed

  1. A call to the main line is written down as it starts. A call to an agent’s own number rings that agent and nobody else, whatever the closed switch says.
  2. If the closed switch is on, the caller hears the closed greeting and is asked to leave a message.
  3. Otherwise the caller hears the menu and presses a digit. Star lets the caller dial an extension instead; see Reach an agent by extension or personal line. No answer after the menu’s retries ends with a goodbye.
  4. The digit picks a department. A department that is closed for the day, on holiday, or outside its hours sends the caller to the closed greeting and voicemail.
  5. An open department puts the caller in that department’s queue. The department’s agents ring for the department’s ring length; a task nobody takes falls back to the main queue, where every agent is a target.
  6. While waiting, the caller is offered a callback at the callback interval. A caller who accepts types or confirms a number, and a callback request is filed for the department.
An agent with no department of their own belongs to every active department. A developer runs a script that writes TaskRouter’s shape from the departments here: one queue per active department, the main queue as the catch-all, and a per-department rule that rings the department’s own queue for its ring length and then the main queue.

What a call ends as

The call’s department, whether it came after hours, its queue time and its result are written on the call record as each event arrives.

Texts

An inbound text lands in a conversation on the engine’s side. A photo sent with it is copied into the engine’s own storage, because Twilio’s copy needs the account’s login to view. An outbound text is queued by the engine, sent through Twilio, and its delivery receipt comes back to the phone function. Card numbers are masked on the way in; see How card numbers stay out of texts and transcripts.

Where the keys live

The Twilio account, its API key and its auth token live in the database’s encrypted vault, filled from the phone group described on Environments and secrets. A database function hands them to the phone function; nothing in a function’s environment holds them. The auth token is what every incoming post is checked against, so a phone function that cannot read it refuses every call with “service unavailable”.

What Twilio talks to