Skip to main content
When your Twilio numbers need to be connected to multiple downstream systems, this can be configured inside your Twilio environment. Twilio gives you the core building blocks to receive inbound messaging events, invoke multiple downstream webhooks, and support outbound messaging from more than one business system. Your data should never be stuck with a single vendor. By using this guide you can allow two systems to send and receive from the same phone number.

Setting Up the Inbound Webhook

The user Messages the Number What Happens Next

Option 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

  1. Sign in to Twilio Console.
  2. Buy a phone number or select an existing SMS-enabled number.
  3. Open the number settings.
  4. Confirm SMS is enabled.

Step 2: Create a Studio Flow

  1. Open Studio in Twilio Console.
  2. Create a new Flow.
  3. Start with a blank Flow.
  4. Name it something like Inbound SMS Dual System Routing.
  5. Add the Incoming Message trigger.

Step 3: Add the first webhook call

  1. Add a Make HTTP Request widget after Incoming Message.
  2. Point it to System A.
Example:
POST https://system-a.example.com/webhooks/inbound-sms
Pass fields such as:
  • MessageSid
  • From
  • To
  • Body

Step 4: Add the second webhook call

  1. Add another Make HTTP Request widget.
  2. Point it to System B.
Example:
POST https://system-b.example.com/webhooks/inbound-sms

Step 5: Connect the Flow

Use a simple sequence:
Incoming Message
-> HTTP Request to System A
-> HTTP Request to System B
-> Send Message or End

Step 6: Attach the Flow to the number

  1. Go back to the phone number settings.
  2. Under A message comes in, choose Studio Flow.
  3. Select the Flow you created.
  4. 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
In that setup, the number points to a Function, and the Function calls System A and System B from inside Twilio.

Example inbound Twilio Function

This example receives an inbound SMS in Twilio, forwards it to both downstream systems, and returns a simple TwiML response.
exports.handler = async function(context, event, callback) {
  const axios = require('axios');
  const twiml = new Twilio.twiml.MessagingResponse();

  const payload = {
    provider: 'twilio',
    event_type: 'inbound_message',
    message_sid: event.MessageSid,
    from: event.From,
    to: event.To,
    body: event.Body,
    account_sid: event.AccountSid
  };

  try {
    await Promise.allSettled([
      axios.post('https://system-a.example.com/webhooks/inbound-sms', payload, {
        headers: {
          Authorization: `Bearer ${context.SYSTEM_A_API_KEY}`,
          'Content-Type': 'application/json'
        }
      }),
      axios.post('https://system-b.example.com/webhooks/inbound-sms', payload, {
        headers: {
          Authorization: `Bearer ${context.SYSTEM_B_API_KEY}`,
          'Content-Type': 'application/json'
        }
      })
    ]);

    twiml.message('Thanks, we received your message.');
    return callback(null, twiml);
  } catch (error) {
    console.error(error);
    return callback(error);
  }
};

How to use it in Twilio

  1. Go to Functions & Assets in Twilio Console.
  2. Create a new Function.
  3. Paste in the code.
  4. Add environment variables for SYSTEM_A_API_KEY and SYSTEM_B_API_KEY.
  5. Deploy the Function.
  6. Attach the Function URL to the number under A message comes in.
  7. 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 number

Option 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:
{
  "source_system": "system_a",
  "to": "+15551234567",
  "from": "+15557654321",
  "body": "Your appointment is confirmed"
}

Example outbound Twilio Function

This example accepts a request from either downstream system and sends an SMS through Twilio.
exports.handler = async function(context, event, callback) {
  const client = context.getTwilioClient();

  try {
    const message = await client.messages.create({
      to: event.to,
      from: event.from,
      body: event.body,
      statusCallback: 'https://your-function-domain.twil.io/status-callback'
    });

    return callback(null, {
      success: true,
      source_system: event.source_system,
      message_sid: message.sid,
      status: message.status
    });
  } catch (error) {
    console.error(error);
    return callback(null, {
      success: false,
      error: error.message
    });
  }
};

Step 2: Send the SMS from the Function

The Function should call the Twilio Messaging API using:
  • From
  • To
  • Body
  • StatusCallback

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
If both systems need delivery visibility, using a Twilio Function for callbacks is the cleaner option.

Example status callback Function

exports.handler = async function(context, event, callback) {
  const axios = require('axios');

  const payload = {
    message_sid: event.MessageSid,
    message_status: event.MessageStatus,
    to: event.To,
    from: event.From,
    error_code: event.ErrorCode || null,
    error_message: event.ErrorMessage || null
  };

  try {
    await Promise.allSettled([
      axios.post('https://system-a.example.com/webhooks/message-status', payload, {
        headers: {
          Authorization: `Bearer ${context.SYSTEM_A_API_KEY}`,
          'Content-Type': 'application/json'
        }
      }),
      axios.post('https://system-b.example.com/webhooks/message-status', payload, {
        headers: {
          Authorization: `Bearer ${context.SYSTEM_B_API_KEY}`,
          'Content-Type': 'application/json'
        }
      })
    ]);

    return callback(null, { success: true });
  } catch (error) {
    console.error(error);
    return callback(null, { success: false, error: error.message });
  }
};

Step 4: Let both systems call the outbound Function

Give both systems the same Twilio Function endpoint for outbound requests. That keeps the send logic inside Twilio and avoids duplicating outbound setup across both systems.