ToothFairyAI — Twilio SMS Integration Guide
This guide shows how to connect your ToothFairyAI agents to Twilio SMS services for automated text messaging.
Your agents will be able to receive SMS messages via webhook and respond automatically through Twilio's messaging API.
How it works (at a glance)
SMS received → Twilio → Webhook → ToothFairyAI Agent → Response → Twilio → SMS sent:
- Twilio Setup: Create account, purchase phone number, configure messaging service
- Webhook Configuration: Set ToothFairyAI webhook URL in Twilio messaging service
- Channel Creation: Create SMS channel in ToothFairyAI with Twilio credentials
- Agent Configuration: Assign SMS channel to your agent and set phone number
- Agent receives SMS messages and responds automatically via Twilio
SMS messages are charged by Twilio according to their pricing. Check Twilio's pricing page for current rates.
Prerequisites
- A ToothFairyAI workspace (Chat agents only support channels)
- A Twilio account with SMS capabilities
- A purchased Twilio phone number
- Agent configured in Chat mode (Operator, Assistant, or Programmer)
You must purchase a phone number from Twilio to send and receive SMS messages. Free trial accounts may have limitations on messaging capabilities.
Step 1: Twilio Account Setup
1.1) Create Twilio Account
- Go to twilio.com and create an account
- Complete the verification process
- Navigate to the Twilio Console Dashboard
1.2) Purchase a Phone Number
- In the Twilio Console, go to Phone Numbers > Manage > Buy a number
- Select your country and desired capabilities:
- ✅ SMS (required)
- ✅ Voice (optional)
- Choose a phone number and click Buy
- Note down your purchased phone number (e.g.,
+1234567890)
1.3) Get Account Credentials
- In the Twilio Console, go to Account > API keys & tokens
- Note down your Account SID (starts with
AC...) - Note down your Auth Token (keep this secure)
Your Auth Token is sensitive information. Store it securely and never share it publicly.
Step 2: Create Messaging Service
2.1) Create New Messaging Service
- In Twilio Console, go to Messaging > Services
- Click Create Messaging Service
- Enter a friendly name (e.g., "ToothFairyAI Integration")
- Select Defer to sender's webhook as the use case
- Click Create Messaging Service
2.2) Add Phone Number to Service
- In your messaging service, go to Sender Pool
- Click Add Senders
- Select Phone Number and choose your purchased number
- Click Add Phone Numbers
2.3) Configure Webhook URL
- In your messaging service, go to Integration
- In the Incoming Messages section:
- Webhook URL:
https://api.toothfairylab.link/webhooks/twilio/{WORKSPACE_ID} - HTTP Method:
POST - Replace
{WORKSPACE_ID}with your actual workspace ID
- Webhook URL:
Your workspace ID can be found in ToothFairyAI under Settings > General. It's a UUID format like 6586b7e6-683e-4ee6-a6cf-24c19729b5ff.
2.4) Save and Activate
- Click Save Configuration
- Go to Properties tab and click Start Messaging Service
Step 3: Create SMS Channel in ToothFairyAI
3.1) Navigate to Channels
- Log into your ToothFairyAI workspace
- Go to Settings > Channels
- Click Create
3.2) Configure Channel Settings
Fill in the following details:
- Provider Name:
Twilio SMS(or your preferred name) - Description:
SMS integration via Twilio(optional) - Channel Type: Select
SMSfrom dropdown - Provider: Select
Twilio for SMSfrom dropdown - Token: Enter your Twilio Auth Token (from Step 1.3)
- Account ID: Enter your Twilio Account SID (from Step 1.3)
3.3) Save Channel
- Click Save to create the channel provider
- Note that ToothFairyAI will generate a unique webhook URL for this channel
After creating the channel, ToothFairyAI automatically generates the webhook URL that you configured in Step 2.3. This URL handles incoming SMS messages from Twilio.
Step 4: Configure Agent for SMS
4.1) Select Your Agent
- Go to Settings > Agents
- Select the agent you want to connect to SMS
- Make sure it's configured as a Chat agent (Operator, Assistant, or Programmer mode)
4.2) Configure Agent Channels
- Scroll down to Agent Channels section
- Assign custom channels: Select your created Twilio SMS channel
- Phone number: Enter the Twilio phone number you purchased (e.g.,
+1234567890)
When entering the phone number, remove the + symbol. For example, if your phone number is +61468019327, enter it as 61468019327 in the phone number field.
- Delivery delay: Set delay between 0-120 seconds (optional, simulates human response time)
- New chat on received msg.: Enable if you want each SMS to start a new conversation