Twilio Service Integration with Bitrix24
Twilio is chosen when you need international SMS, WhatsApp Business API, or two-way messaging with customers. Russian providers dominate the domestic market, but for companies with international clients — exporters, SaaS services, logistics operators — Twilio remains the primary tool. Integration with Bitrix24 allows you to send SMS and WhatsApp messages from CRM, receive customer responses in the deal timeline, and automate communication via robots.
Connecting Twilio via messageservice
Provider registration — standard for Bitrix24 messageservice module:
messageservice.sender.add({
CODE: "twilio_sms",
TYPE: "SMS",
HANDLER: "https://your-domain.com/handler/twilio.php"
})
The handler receives a request from Bitrix24 and translates it to the Twilio Programmable SMS API:
POST https://api.twilio.com/2010-04-01/Accounts/{AccountSID}/Messages.json
Body:
To: +NUMBER
From: +TWILIO_NUMBER
Body: TEXT
StatusCallback: https://your-domain.com/handler/twilio-status.php
Authentication — HTTP Basic Auth with AccountSID and AuthToken. The StatusCallback parameter — URL to which Twilio will send POST when message status changes.
A key difference from Russian providers: Twilio requires a verified sender number (From). The number is purchased in the Twilio console — you can choose the country, type (local, toll-free, mobile) and even specific digit combinations.
Two-Way Messaging
Most Russian SMS providers work one-way: company sends SMS, client can't reply. Twilio supports full two-way messaging.
Scheme:
- Company sends SMS to client from Twilio number.
- Client replies with regular SMS to that number.
- Twilio sends POST request (webhook) to the configured URL with reply text and sender number.
- Handler creates activity in Bitrix24 timeline via
crm.activity.addor incoming message in open line.
In practice, two-way messaging is used for:
- Appointment confirmation. SMS: "Confirm appointment at 3:00 PM, reply YES". Client replies — robot changes deal stage.
- Quick feedback. After service: "Rate from 1 to 5". Response is saved in contact custom field.
- Support. Client asks a question via SMS — message goes to Bitrix24 open line, manager responds from CRM.
To handle incoming replies, a webhook is configured in Twilio Console at the number level: Messaging → Configure → A MESSAGE COMES IN → handler URL.
WhatsApp Business via Twilio
Twilio is an official WhatsApp Business API provider. Connecting to Bitrix24 gives managers a communication channel with 90%+ open rate (vs 20–30% for SMS).
Setup:
- WhatsApp sender registration in Twilio Console. Goes through Meta moderation — requires verified Facebook business account.
- Message templates. WhatsApp requires pre-approved templates to initiate conversation. Templates are created in Twilio Console and approved by Meta.
-
Sending from Bitrix24. Via separate handler or existing extension: if number starts with
whatsapp:, request goes through Twilio WhatsApp API.
In Bitrix24, WhatsApp messages can be implemented two ways:
- Via messageservice — as SMS provider, but with WhatsApp message type. Manager selects channel when sending.
-
Via open lines — connecting Twilio WhatsApp as an open line channel via REST API (
imopenlines.network.join). Customer messages go to Bitrix24 chat, replies go through WhatsApp.
The second option is preferable for support and sales — manager works in the familiar Bitrix24 chat interface.
Number Verification and Verify API
Twilio Verify — separate service for sending one-time codes (OTP). Application in Bitrix24 context:
-
Customer number confirmation when creating lead: CRM robot sends code via Verify API, client enters code on site, webhook confirms number and updates field
UF_CRM_PHONE_VERIFIED. - Two-factor authentication for personal account access integrated with Bitrix24.
Verify API is charged separately and costs less than regular SMS, as Twilio optimizes routing for OTP.
Delivery Statuses
Twilio sends callback to StatusCallback URL with each status change:
| Twilio Status | Meaning | Action in Bitrix24 |
|---|---|---|
queued |
In queue | — |
sent |
Sent to operator | Status "Sent" |
delivered |
Delivered | Status "Delivered" |
undelivered |
Not delivered | Status "Error" + reason note |
failed |
Send error | Status "Error" + manager notification |
Twilio provides ErrorCode and ErrorMessage for failed sends. Typical issues: 21211 — invalid number, 21614 — number doesn't support SMS, 30004 — recipient blocked sender. Error codes are recorded in deal custom field for analysis.
Cost and International Sending
Twilio charges per segment by destination country. SMS to Russia — $0.043/segment, to USA — $0.0079, to Germany — $0.065. For companies with international base, the cost difference by country is significant.
Optimization:
- Messaging Service. Twilio allows creating a Messaging Service that automatically selects optimal sender number by recipient country. One handler in Bitrix24 — Twilio picks the route.
- Short templates. For Cyrillic limit is 70 characters per segment. For Latin — 160. If client is abroad — English template is twice as cheap.
Implementation Timeline
| Scale | Includes | Timeline |
|---|---|---|
| Basic | Twilio SMS connection, sending from card, one robot | 3–5 days |
| Standard | Robots by stages, two-way messaging, callback statuses | 1 week |
| Extended | WhatsApp Business, Verify API, open lines, Messaging Service | 1.5–2 weeks |
What We Configure
- Twilio registration as SMS provider via
messageservice.sender.add - Handler Bitrix24 → Twilio Programmable SMS API
- Two-way messaging: webhook for incoming SMS → CRM activity
- WhatsApp Business via Twilio: templates, open lines or messageservice
- Twilio Verify for number confirmation
- Callback handler for delivery statuses with error mapping
- Messaging Service for automatic route selection by country
- CRM robots for automatic notifications
- Testing: outgoing SMS, incoming reply, WhatsApp template, Verify OTP, status callback







