# Receive Inbound Messages from SMS, WhatsApp and Facebook Messenger

> \[!NOTE]
>
> This guide is for Flex UI 1.x.x and channels that use Programmable Chat and Proxy. Programmable Chat for Flex will reach end of life on June 1, 2026. If you're new to Flex or currently using Programmable Chat, [build with Flex Conversations](/docs/flex/conversations) or [migrate](/docs/flex/developer/conversations/programmable-chat-to-flex-conversations).

## Overview

With Flex, your customers can reach you via channels like SMS, WhatsApp, and Facebook Messenger. This page details how to configure these Twilio-supported channels.

## Configure SMS

The [Flex Messaging page](https://console.twilio.com/us1/develop/flex/channels/messaging/conversations) in the Twilio Console allows you to register a phone number with Flex to be handled for inbound SMS. When you register a number, we:

1. Link the phone number's messaging handler to Proxy.
2. Create a [Flex Flow](/docs/flex/developer/messaging/manage-flows) that redirects to your custom message handling. This defaults to a Studio Flow.

To manually configure SMS, you will need to update the messaging handler on the [Phone Numbers](https://www.twilio.com/console/phone-numbers/incoming) page. Connect this to your 'Flex Proxy Service', and then use the [Flex Flow API](/docs/flex/developer/messaging/flow) to create a new entry for your number.

## Configure WhatsApp and Facebook

Like SMS, all other messaging channels have a configurable [webhook](/docs/glossary/what-is-a-webhook) for processing inbound messages. You'll need to update the messaging handler for each channel you want to connect to Flex.

For **WhatsApp** you can configure the message handler using the [WhatsApp Sandbox](https://www.twilio.com/console/sms/whatsapp/sandbox). If you're using WhatsApp with Flex Conversations, refer to [Manage Conversations WhatsApp Addresses](/docs/flex/admin-guide/setup/conversations/manage-conversations-whatsapp-addresses).

For **Facebook** and other channels you can configure the callback URL from the [Channels Page](https://www.twilio.com/console/channels).

### Set the message handler

Once you've found the right place in the console to configure the message handler, you can [set the Incoming Message webhook to point to the Flex Proxy Service](/docs/proxy/channels). This webhook looks like:

```bash
https://webhooks.twilio.com/v1/Accounts/ACxx/Proxy/KSxx/Webhooks/Message
```

Your unique URL will replace the `ACxx` and `KSxx` identifiers with your Account SID and Flex Proxy Service SID. You can find your default Flex Proxy instance SID in the [Proxy section of the console](https://www.twilio.com/console/proxy/services). For Flex to handle your messaging channel, the channel needs to be connected to Proxy. Proxy translates all messages between Flex's chat channel (which your agent interacts with) and your messaging channel (which your customers interact with).

## Configure the Flex Flow

As with SMS, you must create a [Flex Flow](/docs/flex/developer/messaging/flow) entity for each identity that you are connecting to Flex.

Create a Flex Flow

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function createFlexFlow() {
  const flexFlow = await client.flexApi.v1.flexFlow.create({
    channelType: "whatsapp",
    chatServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    friendlyName: "WhatsApp Flex Flow",
    "integration.flowSid": "FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  });

  console.log(flexFlow.accountSid);
}

createFlexFlow();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

flex_flow = client.flex_api.v1.flex_flow.create(
    channel_type="whatsapp",
    chat_service_sid="ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    friendly_name="WhatsApp Flex Flow",
    integration_flow_sid="FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
)

print(flex_flow.account_sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.FlexApi.V1;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var flexFlow = await FlexFlowResource.CreateAsync(
            channelType: FlexFlowResource.ChannelTypeEnum.Whatsapp,
            chatServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            friendlyName: "WhatsApp Flex Flow",
            integrationFlowSid: "FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

        Console.WriteLine(flexFlow.AccountSid);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.flexapi.v1.FlexFlow;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        FlexFlow flexFlow =
            FlexFlow.creator("WhatsApp Flex Flow", "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", FlexFlow.ChannelType.WHATSAPP)
                .setIntegrationFlowSid("FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                .create();

        System.out.println(flexFlow.getAccountSid());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	flex "github.com/twilio/twilio-go/rest/flex/v1"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &flex.CreateFlexFlowParams{}
	params.SetChannelType("whatsapp")
	params.SetChatServiceSid("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
	params.SetFriendlyName("WhatsApp Flex Flow")
	params.SetIntegrationFlowSid("FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")

	resp, err := client.FlexV1.CreateFlexFlow(params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.AccountSid != nil {
			fmt.Println(*resp.AccountSid)
		} else {
			fmt.Println(resp.AccountSid)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$flex_flow = $twilio->flexApi->v1->flexFlow->create(
    "WhatsApp Flex Flow", // FriendlyName
    "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", // ChatServiceSid
    "whatsapp", // ChannelType
    ["integrationFlowSid" => "FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"]
);

print $flex_flow->accountSid;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

flex_flow = @client
            .flex_api
            .v1
            .flex_flow
            .create(
              channel_type: 'whatsapp',
              chat_service_sid: 'ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
              friendly_name: 'WhatsApp Flex Flow',
              integration_flow_sid: 'FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
            )

puts flex_flow.account_sid
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:flex:v1:flex-flows:create \
   --channel-type whatsapp \
   --chat-service-sid ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
   --friendly-name "WhatsApp Flex Flow" \
   --integration.flow-sid FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
```

```bash
curl -X POST "https://flex-api.twilio.com/v1/FlexFlows" \
--data-urlencode "ChannelType=whatsapp" \
--data-urlencode "ChatServiceSid=ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
--data-urlencode "FriendlyName=WhatsApp Flex Flow" \
--data-urlencode "Integration.FlowSid=FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "sid": "FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "date_created": "2016-08-01T22:10:40Z",
  "date_updated": "2016-08-01T22:10:40Z",
  "friendly_name": "WhatsApp Flex Flow",
  "chat_service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "channel_type": "whatsapp",
  "contact_identity": "12345",
  "enabled": true,
  "integration_type": "studio",
  "integration": {
    "flow_sid": "FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    "retry_count": 1
  },
  "long_lived": true,
  "janitor_enabled": true,
  "url": "https://flex-api.twilio.com/v1/FlexFlows/FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
```

When Flex receives a new message, it first sends to Proxy and posts to a new Chat Channel. Afterwards, the message handler redirects to whatever destination you specified in your Flex Flow. By default this is a [Studio Flow](/docs/studio). The Studio Flow can send automated responses to your inbound message or collect any additional information before passing the conversation to an agent in Flex.

You can modify or remove existing Flex Flows from the [Flex Messaging page](https://console.twilio.com/us1/develop/flex/channels/messaging/conversations) in the Twilio Console.
