Integrating Twilio and Zendesk for SMS Messaging
Time to read:
Integrating Twilio and ZenDesk for SMS Messaging
If you’re building a modern customer support experience, speed, context, and flexibility are key. Zendesk gives your team a powerful ticketing and help desk system—but what if your agents could also send and receive SMS messages from within their support tools?
That’s where Twilio comes in.
In this tutorial, we’ll show you how to integrate Twilio with Zendesk to add programmable messaging capabilities to your support workflows. When this tutorial is complete, you'll be able to do SMS integration with Zendesk. This will allow you to send and receive messages from Zendesk. Your customers can send a quick SMS message to your support team, and the SMS will be used to create a Zendesk ticket. Your team can also use SMS to directly message customers with automated Zendesk updates.
Prerequisites
To complete this tutorial, you will need:
- A (free) Twilio account
- A Zendesk account with admin access (Zendesk's Free Trial lasts 14 days)
- Basic familiarity with APIs and Webhooks
Step 1: Set Up Your Twilio Phone Number
If you don't have a Twilio phone number yet, the first step is to buy a number. To do this:
- Log in to your Twilio Console.
- Navigate to Phone Numbers → Manage → Buy a Number using the left-hand navigation bar.
- Make sure your chosen number supports SMS.
- Click Buy to select your number.
Step 2: Configure a Webhook to Send SMS When a Zendesk Ticket is Created
Zendesk lets you trigger HTTP requests when a ticket is created or updated. Here’s how to send an SMS using Twilio when a new ticket comes in:
First, in Zendesk, go to Admin Center → Apps and Integrations → Webhooks using the left-side navigation.
Click Create Webhook. Here, you'll be given the option of creating a Webhook using Zendesk events, or Trigger or Automation. If you want to learn more about Zendesk events, the Zendesk documentation has a page that you can browse. This article explains more about the ways to create a Webhook in Zendesk. For this tutorial, choose Trigger or Automation.
Click Next.
Add Details. Use the following details in the available boxes. Replace the placeholder for your account SID with your actual account SID from the Twilio dashboard.
- Name: Twilio Ticket Alert
- Description: This is optional, so you can leave it blank or write any description you want.
- Endpoint URL: https://api.twilio.com/2010-04-01/Accounts/YOUR_ACCOUNT_SID/Messages.json
- Method: POST
- Request Format: Form Encoded
- Authentication: Basic Auth (use your Twilio SID as Username and and Auth Token as Password)
Click Create webhook, and Finish Setup. You will get a message reminding you that your webhook needs to be connected to a trigger or automation to work. That is the next step. In the Admin Center, go to Objects and Rules → Business Rules → Triggers.
Here, you can choose to select any trigger that would prompt an SMS. This can get very robust and allow for a lot of different active triggers. For this demonstration, we'll choose to send an SMS to our agent whenever a new ticket is created. Look for the Create Trigger button. Add the following parameters:
- Trigger Name: Ticket Created
- Description: Optional
- Trigger Category: Notifications
For Conditions, you want to create conditions that show a ticket is created. Choose Category: Ticket, Operator: Is, and Value: Created, as in the screenshot below.
Now you have to set up your Action. Zendesk has a lot of actions available for users, so you want to look under Category → Notify By in order to find the Active Webhook option.
Now you can choose the webhook that you created in the previous step as your action. In order to send the parameters properly from Zendesk to Twilio, this must be sent as an unformatted request . This requires the following key-value pairs to be added to the POST request:
- To: Your to number, in E. 164 format, such as +15557771234
- From: Your Twilio number, also in E. 164 format
- Body: Your message; eg. 'A ticket was created.'
Click Create.
Your connection is now live. Now, when a new ticket is created, Twilio will send an SMS to the chosen To number with the body message. This is a very simple example, but will allow your agent at the provided number to be aware of updated ticket changes and statuses.
Step 3: Route Incoming Messages to Zendesk
Twilio can receive incoming SMS and forward them to your Zendesk instance. For our implementation, we will use Twilio Functions, which is built into Twilio and requires no additional account setup. You can also use your own backend endpoint (for a more robust solution), or you can use Zapier or Make.com if you want a no-code solution.
You will need your Zendesk API token to create this integration.
In Zendesk, go to Apps and Integrations → APIs → API tokens.
You will have to agree to creating the API token to unlock this functionality. Generate a new token. Once the API token is generated, save it somewhere safe because you will not see it again.
Now to create your Twilio Function:
- Go to the Twilio Console → Functions and Assets → Services.
- Create your Service. Create a name for your Service and call it
zendesk-service - Now you are in the Functions layout. Click on Create your Function.
- For your service you will need to provide Environment Variables. Look for Environment Variables on the left side tab.
In your Twilio Console → Functions → Environment Variables, add the following key pairs
- ZENDESK_SUBDOMAIN: your subdomain from your Zendesk account, such as 'mycompany123'
- ZENDESK_EMAIL: email@mycompany.com
- ZENDESK_API_TOKEN: your API token generated earlier
Make sure you toggle Enable ACCOUNT_SID and AUTH_TOKEN so you can access them if needed.
Create a new Function and replace the placeholder code with this:
Whatever you have named your Function, you will have to set it to Public using the little icon to the side of the function. It should look like a globe shape if the function is public. If you see a lock here, click on that and change it as shown. Setting the function to Public will allow it to be accessed from the rest of the internet, and, therefore, Zendesk's API.
Now, deploy the function using the Deploy All button.
Assign it as the Messaging webhook for your Twilio number. You can do this by choosing your Twilio Number, going to Messaging Configuration, and choosing the service you've created. Then select the Function Path to reach the function. Keep in mind that in some countries, you will need to use Toll Free or 10DLC verification to send automated text messages. Always follow the rules for your region.
You're done! Now you can send a text message to your Twilio registered number. The body of the text message will be created as a Ticket in Zendesk, and the user sending the text message will receive a short confirmation message in SMS that their ticket was filed. Try it out by sending a text to your Twilio number. You should see a newly created Ticket in Zendesk.
What’s Next?
You’ve just laid the foundation for a modern, mobile-first support experience powered by Zendesk and Twilio. From here, you can:
- Add support for WhatsApp
- Add support for Voice using Twilio's built in integration.
- Use Twilio Studio to build visual workflows
- Build routing logic with Twilio Flex for contact center-grade support
Great support is proactive, fast, and meets customers where they are. With Twilio and Zendesk together, you can build SMS- and voice-based workflows that your customers will actually use—and your agents will love.
Let's build something amazing together!
Amanda Lange is a .NET Engineer of Technical Content. She is here to teach how to create great things using C# and .NET programming. She can be reached at amlange [ at] twilio.com.
Related Posts
Related Resources
Twilio Docs
From APIs to SDKs to sample apps
API reference documentation, SDKs, helper libraries, quickstarts, and tutorials for your language and platform.
Resource Center
The latest ebooks, industry reports, and webinars
Learn from customer engagement experts to improve your own communication.
Ahoy
Twilio's developer community hub
Best practices, code samples, and inspiration to build communications and digital engagement experiences.