Skip to the page

Recipes

Moving from Twilio recipes

Swap a Twilio send for BlueBot’s and text from your own number instead of a rented one.

Three recipes for Moving from Twilio. Each names its trigger and the BlueBot step, lists the fields to map and says how to test it with your own number before anyone else gets a text.

How Moving from Twilio connects

  • API: Your own code calls BlueBot’s REST API and listens to its signed webhooks.

Move a send from Twilio to BlueBot

PartWhat it is
TriggerYour code sends a text
ActionPOST /v1/messages
Connects throughAPI

Steps

  1. Replace the call to Twilio’s Messages API with POST /v1/messages.
  2. Send the fields to and text where you sent To and Body, and drop From, since BlueBot sends from your own number.
  3. Add an Idempotency-Key so a retried request never sends twice.

Map the fields

BlueBot fieldMap it to
toThe person’s mobile number from Moving from Twilio. US numbers can leave off the +1.
textYour appointment is confirmed for tomorrow at 10 AM. Reply here with any questions.
metadatasource set to twilio, and record_id set to the record’s id, so the status and reply webhooks for this text can find the record again.
serviceAuto, the default: iMessage when the person uses it, otherwise SMS through your iPhone.
POST/v1/messagesSend a text →
curl -X POST "https://usebluebot.com/api/v1/messages" \
  -H "Authorization: Bearer $BLUEBOT_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: twilio-1042" \
  -d '{
    "to": "+15555550123",
    "text": "Your appointment is confirmed for tomorrow at 10 AM. Reply here with any questions.",
    "metadata": {
      "source": "twilio",
      "record_id": "1042"
    }
  }'

Test it

Run the request with your own number in to. A text arrives on your phone from your own number.

Move your inbound webhook

PartWhat it is
TriggerA text comes in (BlueBot’s message.received webhook)
ActionA webhook for message.received starts it, and Moving from Twilio takes the text
Connects throughAPI

Steps

  1. Add your endpoint in BlueBot as a webhook for message.received.
  2. Read the sender and the words from the JSON body, where Twilio sent From and Body as form fields.
  3. Check the webhook-signature header with your whsec_ secret in place of X-Twilio-Signature.

Map the fields

From BlueBotInto Moving from Twilio
data.fromThe phone number to find the person by in Moving from Twilio. It’s in E.164 (+15555550123); search by the last 10 digits if Moving from Twilio stores numbers another way.
data.textThe words, for a note, a row or a message. Null when the person sent only a picture.
data.received_atWhen it came in, in UTC.
data.filesPictures and voice memos. Each url works for an hour, so copy a file you want to keep.
data.chat_idSet when the text came in a group chat; null for a one-to-one text.

Test it

Run bluebot listen --forward-to http://localhost:3000/webhooks, then text your BlueBot number from another phone. The CLI forwards the event to your handler, signed. BlueBot copies texts from people you’ve texted through it, unless you set Which chats to copy to Everything.

Move your status callbacks

PartWhat it is
TriggerA text you sent changes state
ActionMoving from Twilio acts on what BlueBot reports
Connects throughAPI

Steps

  1. Put your own IDs in metadata when you send.
  2. Subscribe to message.delivered, message.read and message.failed, each of which carries that metadata.
  3. Read the hold on a queued text to see why it’s waiting, such as quiet hours.

Map the fields

From BlueBotInto Moving from Twilio
data.statesent, delivered, read, failed or expired, for a field or a filter.
data.metadataThe record_id you sent with the text, to find the record it was for.
data.failure.reasonWhy a failed text didn’t go: not_on_imessage, messages_refused or file_unavailable.
data.toWho the text was for.

Test it

Send one text to your own number, then look for the event. To try the step without sending anything, POST /v1/webhooks/{id}/test sends an example of any event type to your webhook.

Before you turn it on

  • Text only people who asked to hear from you. Anyone who replies STOP goes on your stop list, and BlueBot cancels texts to them. Stop words
  • A text that can’t go yet waits with a hold rather than failing: quiet hours, your Mac away, a daily limit. Holds
  • Moving from Twilio with BlueBot on the integrations page says what else the two do together.