Closed beta · run Worlds on your machineBrowse worlds →
Docs menu · Twilio API

Worlds / Comms and scheduling

Twilio API

A local Twilio account with phone numbers, messaging services, SMS and calls, opt-outs and delivery status callbacks. Test the agent that sends reminders and replies by text, and respects who opted out.

Base path
/2010-04-01/Accounts/{AccountSid}
Auth
Account SID and auth token over HTTP basic auth, the world key
Endpoints
15
Status
Active today

This reference previews the surface the Twilio world serves in the closed beta. Paths mirror the public Twilio API; the exact subset is confirmed when your workflow is scoped.

Connect

The run gives your agent these bindings. Keep your SDK; change only where it sends requests.

bindingmeaning
WORLDS_TWILIO_URLThis world's origin followed by /2010-04-01/Accounts/{AccountSid}
WORLDS_API_KEYThe world key, accepted wherever Twilio expects a credential
WORLDS_WORLD_IDThe isolated world's identity
js · twilio
import twilio from "twilio";

const client = twilio("ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", process.env.WORLDS_API_KEY);
client.api.baseUrl = process.env.WORLDS_TWILIO_URL;

const message = await client.messages.create({
  to: "+15558675310",
  from: "+15017122661",
  body: "Your order shipped",
});

API reference

Messages

SMS and MMS sent and received.

  • POST/2010-04-01/Accounts/{AccountSid}/Messages.jsonSend a message
  • GET/2010-04-01/Accounts/{AccountSid}/Messages.jsonList messages
  • GET/2010-04-01/Accounts/{AccountSid}/Messages/{Sid}.jsonFetch a message
  • POST/2010-04-01/Accounts/{AccountSid}/Messages/{Sid}.jsonUpdate or redact a message
Fields · 6
sidstringMessage SID
tostringRecipient number
fromstringSender number
bodystringMessage text
statusstringqueued, sent, delivered, failed and more
date_sentdatetimeTime sent

Calls

Voice calls placed and received.

  • POST/2010-04-01/Accounts/{AccountSid}/Calls.jsonCreate a call
  • GET/2010-04-01/Accounts/{AccountSid}/Calls.jsonList calls
  • GET/2010-04-01/Accounts/{AccountSid}/Calls/{Sid}.jsonFetch a call
  • POST/2010-04-01/Accounts/{AccountSid}/Calls/{Sid}.jsonUpdate or end a call
Fields · 5
sidstringCall SID
tostringCalled number
fromstringCalling number
statusstringqueued, ringing, in-progress, completed and more
durationstringLength in seconds

Incoming phone numbers

Numbers on the account and their webhooks.

  • GET/2010-04-01/Accounts/{AccountSid}/IncomingPhoneNumbers.jsonList numbers
  • POST/2010-04-01/Accounts/{AccountSid}/IncomingPhoneNumbers.jsonBuy a number
  • POST/2010-04-01/Accounts/{AccountSid}/IncomingPhoneNumbers/{Sid}.jsonUpdate a number
  • DELETE/2010-04-01/Accounts/{AccountSid}/IncomingPhoneNumbers/{Sid}.jsonRelease a number
Fields · 5
sidstringNumber SID
phone_numberstringNumber in E.164 format
friendly_namestringLabel
sms_urlstringWebhook for texts
voice_urlstringWebhook for calls

Recordings

Audio recordings of calls.

  • GET/2010-04-01/Accounts/{AccountSid}/Recordings.jsonList recordings
  • GET/2010-04-01/Accounts/{AccountSid}/Recordings/{Sid}.jsonFetch a recording
  • DELETE/2010-04-01/Accounts/{AccountSid}/Recordings/{Sid}.jsonDelete a recording
Fields · 4
sidstringRecording SID
call_sidstringCall it belongs to
durationstringLength in seconds
statusstringin-progress, completed or absent

Test workflow

  1. Prepare. Select the Twilio setup for your workflow and review its starting records, including messages, calls, incoming phone numbers.
  2. Connect. Configure your agent with this world's URL and key using the SDK example. Check that it reaches the intended API before running a test.
  3. Define. Describe the task, expected final changes and records that must stay untouched. Keep expected outcomes separate from the agent's instructions.
  4. Run and inspect. Use the dashboard or your workflow's generated CLI setup. Review final records and changes, then rerun from the same starting setup with the relevant failure conditions. Use Deployment and CI to automate the same workflow.

What to verify

  • No messages to opted-out numbers
  • 0142 reply sent from the number they texted
  • One reminder per patient, no duplicates
  • HELP reply sent to 0188
  • No calls placed

Test file

A task file names the jobs, the policy your agent is given and what the grader reads back from the world's final state. The agent never sees the expected outcomes.

yaml · worlds/tasks.yaml
# worlds/tasks.yaml · Twilio
version: 2
connector: twilio
seed: twilio-starter
mode: isolated
policy: >
  Send tomorrow's appointment reminders and answer reschedule requests. Skip
  anyone who has opted out, and reply from the number each patient texted.
tasks:
  - id: send-appointment-reminders-from-the-right-number
    prompt: Send appointment reminders from the right number
  - id: reply-to-inbound-texts-in-the-same-conversation
    prompt: Reply to inbound texts in the same conversation
  - id: honor-stop-and-help-keywords
    prompt: Honor STOP and HELP keywords
expected:
  - No messages to opted-out numbers
  - 0142 reply sent from the number they texted
  - "One reminder per patient, no duplicates"
  - HELP reply sent to 0188
  - No calls placed
scenarios:
  - opted-out
  - invalid-number
  - carrier-filtered

See Tasks and outcomes for every field, and Deployment and CI to run the file on every pull request.

Failure conditions

Each one fires before the handler, at the same step on every run.

conditionwhat the agent sees
opted-outSending to a STOP recipient returns error 21610
invalid-numberA bad To number returns error 21211
carrier-filteredThe message ends undelivered with 30007
rate-limitedThe API returns 429 with error 20429
callback-twiceThe delivered status callback arrives two times

Starting data

Start each run from the same records and relationships. The overview below describes the Twilio starter; use the setup supplied for your workflow when preparing your own snapshot.

RecordsStarting setup
numbers3 long codes and 1 toll-free number on a messaging service
messages800 messages, queued, sent, delivered, undelivered and failed
opt-outs40 recipients who replied STOP
callsCall logs with status and duration
status callbacksDelivery callbacks for every message

The record shapes below reuse this world's API field definitions. They show illustrative values and placeholders, not an importable seed. API responses and seed input can differ; include all required records and references in the accepted import format for your workflow.

Messages records

Messages

SMS and MMS sent and received.

FieldTypeMeaning / relationship
sidstringMessage SID
tostringRecipient number
fromstringSender number
bodystringMessage text
statusstringqueued, sent, delivered, failed and more
date_sentdatetimeTime sent
json · illustrative record shape
{
  "sid": "<Message SID>",
  "to": "<Recipient number>",
  "from": "<Sender number>",
  "body": "<Message text>",
  "status": "<queued, sent, delivered, failed and more>",
  "date_sent": "<Time sent>"
}

See messages operations

Calls records

Calls

Voice calls placed and received.

FieldTypeMeaning / relationship
sidstringCall SID
tostringCalled number
fromstringCalling number
statusstringqueued, ringing, in-progress, completed and more
durationstringLength in seconds
json · illustrative record shape
{
  "sid": "<Call SID>",
  "to": "<Called number>",
  "from": "<Calling number>",
  "status": "<queued, ringing, in-progress, completed and more>",
  "duration": "<Length in seconds>"
}

See calls operations

Incoming phone numbers records

Incoming phone numbers

Numbers on the account and their webhooks.

FieldTypeMeaning / relationship
sidstringNumber SID
phone_numberstringNumber in E.164 format
friendly_namestringLabel
sms_urlstringWebhook for texts
voice_urlstringWebhook for calls
json · illustrative record shape
{
  "sid": "<Number SID>",
  "phone_number": "<Number in E.164 format>",
  "friendly_name": "<Label>",
  "sms_url": "<Webhook for texts>",
  "voice_url": "<Webhook for calls>"
}

See incoming phone numbers operations

Recordings records

Recordings

Audio recordings of calls.

FieldTypeMeaning / relationship
sidstringRecording SID
call_sidstringCall it belongs to
durationstringLength in seconds
statusstringin-progress, completed or absent
json · illustrative record shape
{
  "sid": "<Recording SID>",
  "call_sid": "<Call it belongs to>",
  "duration": "<Length in seconds>",
  "status": "<in-progress, completed or absent>"
}

See recordings operations

See the Twilio world in the catalog