Setting Up the Inbound Webhook
The user Messages the Number What Happens NextOption 1: Use Twilio Studio for the simplest setup
Because a Twilio number points to one inbound handler, the cleanest Twilio-native setup is to use Twilio Studio or a Twilio Function to fan the event out to two downstream systems.Step 1: Buy or select the number
- Sign in to Twilio Console.
- Buy a phone number or select an existing SMS-enabled number.
- Open the number settings.
- Confirm SMS is enabled.
Step 2: Create a Studio Flow
- Open Studio in Twilio Console.
- Create a new Flow.
- Start with a blank Flow.
- Name it something like
Inbound SMS Dual System Routing. - Add the Incoming Message trigger.
Step 3: Add the first webhook call
- Add a Make HTTP Request widget after Incoming Message.
- Point it to System A.
MessageSidFromToBody
Step 4: Add the second webhook call
- Add another Make HTTP Request widget.
- Point it to System B.
Step 5: Connect the Flow
Use a simple sequence:Step 6: Attach the Flow to the number
- Go back to the phone number settings.
- Under A message comes in, choose Studio Flow.
- Select the Flow you created.
- Save the number.
Step 7: Decide reply behavior
- Use Send Message for an automatic reply
- End the Flow with no reply if one of the downstream systems will reply later
Option 2: Use a Twilio Function
Use a Twilio Function instead of Studio if you need:- custom payload mapping
- auth headers
- conditional routing
- more control over webhook handling
Example inbound Twilio Function
This example receives an inbound SMS in Twilio, forwards it to both downstream systems, and returns a simple TwiML response.How to use it in Twilio
- Go to Functions & Assets in Twilio Console.
- Create a new Function.
- Paste in the code.
- Add environment variables for
SYSTEM_A_API_KEYandSYSTEM_B_API_KEY. - Deploy the Function.
- Attach the Function URL to the number under A message comes in.
- Send a test SMS to confirm both systems receive the payload.
Setting Up the Outbound API
How can 2 systems send messages from the same numberOption 1: direct outbound API calls to Twilio
Both downstream systems can call the Twilio Messaging API directly to send SMS from the same Twilio number or Messaging Service. This is the simplest setup, but each system must manage auth, message formatting, and callback handling correctly.Option 2: use a Twilio Function as the outbound API
This is the cleaner Twilio-native setup. In this model:- System A calls a Twilio Function endpoint
- System B calls the same Twilio Function endpoint
- the Function sends the SMS through Twilio
Step 1: Create the outbound Function
Create a Twilio Function that accepts requests from both systems. Example request body:Example outbound Twilio Function
This example accepts a request from either downstream system and sends an SMS through Twilio.Step 2: Send the SMS from the Function
The Function should call the Twilio Messaging API using:FromToBodyStatusCallback
Step 3: Configure status callbacks
Use a Status Callback URL for outbound messages. You can:- send callbacks directly to the originating system, or
- send callbacks to another Twilio Function and forward them from there

