Rate this page:

Post Messages to Slack with Twilio Studio

Post inbound SMS to a Slack feed with Twilio Studio and an incoming Slack webhook. You’ll need an existing Slack team to follow along with this tutorial, so if you don’t have one yet, create one for free now.

We’ll start with a fresh Twilio Studio flow; log into your Twilio account and navigate to the Studio Dashboard, then tap the + icon to create a new flow. You can name your flow anything you like; we’re calling ours SMS to Slack.

SMS to Slack Flow

You’ll notice that the canvas comes with a widget already in place -- that’s the Trigger widget, which kicks off our flow when the trigger we specify is fired. In this case, our trigger is going to be an Incoming Message.

Incoming Message Trigger

This flow only requires one widget -- the HTTP Request widget. Drag one onto the canvas, and connect the dot from the Incoming Message trigger to the dot in the upper left corner of the new widget.

HTTP widget - Post to Slack

You’ll need a Request URL in order to successfully use the HTTP Request widget, and in this case, it’s going to be a Slack webhook URL. Let’s head over to Slack to set up an incoming webhook integration.

Slack has excellent documentation around setting up incoming webhooks, and we encourage you to learn about the available customizations. Today, we’re concerned with the part that is most relevant to the HTTP Request widget -- the webhook URL.

Navigate to the incoming webhooks configuration page and select the channel you’d like to send your inbound SMS to. Click the button to add a new WebHooks integration.

Slack incoming webhook integration

Once you create a new webhook integration, you’ll get a Webhook URL:

Slack webhook URL

Copy this URL to your clipboard; you’ll need it for the HTTP Request widget. Paste the URL into the Request URL field in the sidebar for the HTTP Request widget.

HTTP widget with Slack webhook URL

We’re now halfway there! Once you’ve got the Request URL set up, the next step is to declare a payload (the incoming SMS message). You can do this by setting an HTTP Body in a format that Slack will recognize.

Set the Content Type to Application/JSON so that Slack knows what to expect. To format inbound SMS messages for the payload, set the Request Body field to the following, keeping the curly braces and quote marks in place:

{"text": "{{trigger.message.Body}}"}

Tap the Add button to save your parameters.

Post to Slack Webhook

Your HTTP request is now configured! Time to connect the flow to a Twilio phone number. Navigate to the Phone Numbers section of the Twilio Console, and select the number you’d like to forward from. Scroll down to the Messaging section, and select Webhooks, TwiML Bins, Functions, Studio, or Proxy from the first dropdown. Select Studio Flow next to the “A Message Comes In” dropdown, and choose the flow that you just created to attach it to the number. Click Save.

Connecting the SMS to Slack flow to a Twilio number

Now you can test out your SMS to Slack hook! Send an SMS to your Twilio number, and watch your Slack channel for an inbound message.

SMS message in Slack feed

Want to get creative? You can specify additional payload properties, such as icon_emoji, username, and more. Enjoy watching the stream of messages in your Slack channel!

Mica Swyers Andrej Saweljew Shawn Stern
Rate this page:

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Community Forums or browsing the Twilio tag on Stack Overflow.


        Thank you for your feedback!

        We are always striving to improve our documentation quality, and your feedback is valuable to us. Please select the reason(s) for your feedback or provide additional information about how we can improve:

        Sending your feedback...
        🎉 Thank you for your feedback!
        Something went wrong. Please try again.

        Thanks for your feedback!

        Refer us and get $10 in 3 simple steps!

        Step 1

        Get link

        Get a free personal referral link here

        Step 2

        Give $10

        Your user signs up and upgrade using link

        Step 3

        Get $10

        1,250 free SMSes
        OR 1,000 free voice mins
        OR 12,000 chats
        OR more