Back to Blog
Integration Guides

How to Integrate Twilio with Discord: Step-by-Step Guide

Wire Twilio into Discord to post SMS alerts into channels, notify community members via text, and build SMS verification for server access.

DA
Danial A
Senior Twilio Consultant, Telphi Consulting
June 22, 2026
7 min read
Twilio
Integration
Communications
How to Integrate Twilio with Discord: Step-by-Step Guide

Twilio and Discord connect through Discord's Webhook API and bot framework to post inbound SMS alerts into Discord channels, send outbound SMS notifications to community members, and build phone number verification flows that gate Discord server access behind a Twilio Verify OTP step. This integration is used by developer communities, gaming organizations, and online businesses that run their operations in Discord and need to bridge SMS communication into their server without a separate notification tool. The connection can be built at two levels: a simple Incoming Webhook for one-way SMS-to-Discord posting, or a full Discord bot backed by a server for two-way messaging and verification flows.

What You Need Before You Start

Create a Discord Incoming Webhook by opening your Discord server, right-clicking the target channel, selecting Edit Channel, navigating to the Integrations tab, clicking Create Webhook, giving it a name and optional avatar, and copying the webhook URL in the format https://discord.com/api/webhooks/{webhookId}/{webhookToken}. For a Discord bot-based integration, create an application at https://discord.com/developers/applications, navigate to the Bot section, click Add Bot, copy the bot token, and invite the bot to your server using the OAuth2 URL Generator with the bot scope and the Send Messages and Read Message History permissions. From Twilio, collect your Account SID and Auth Token, and for the verification use case create a Twilio Verify Service in the Console under Verify, then Services, noting the Verify Service SID beginning with VA. Your middleware server needs a public HTTPS endpoint to receive Twilio inbound SMS webhooks and to serve the verification API that your Discord bot or web app will call when a user initiates the phone verification flow.

Step-by-Step Integration Guide

For SMS-to-Discord posting, set your Twilio number's Messaging webhook URL in the Console to your middleware inbound handler, parse the From, Body, and MessageSid from the Twilio POST payload in your middleware, and POST a formatted JSON payload to the Discord webhook URL with the content field set to a string like New SMS from {From}: {Body} and an optional embeds array for richer formatting with fields for the sender, message, and timestamp. For phone verification, implement a Discord slash command using the Discord Interactions endpoint that accepts a user's phone number as a parameter, calls POST https://verify.twilio.com/v2/Services/{ServiceSid}/Verifications with To set to the phone in E.164 format and Channel set to sms to dispatch the OTP, then stores a pending verification record mapping the Discord user ID to the phone number. When the user responds with the OTP code via a second slash command or a Discord modal submission, call POST https://verify.twilio.com/v2/Services/{ServiceSid}/VerificationChecks with To set to the stored phone and Code set to the submitted OTP, check the response status field for approved, and if verified, assign the user a Discord role using the Discord REST API endpoint PUT https://discord.com/api/v10/guilds/{guildId}/members/{userId}/roles/{roleId} with the bot token in the Authorization header as Bot {botToken}. Return HTTP 200 with an empty TwiML Response from your Twilio inbound handler and return the appropriate Discord interaction response JSON from your slash command handler so both platforms receive valid acknowledgment responses.

Common Issues and How to Fix Them

Discord webhook POST requests return 404 when the webhook has been deleted from the channel after the URL was copied, which happens when a server admin removes the webhook integration from the channel settings without notifying the team that configured it. Always verify the webhook exists by sending a GET request to the webhook URL before relying on it in production, and set up monitoring that checks the webhook health on a daily schedule and alerts your team if it returns 404. Discord rate-limits webhook posts to 30 per minute per webhook and 5 per second globally, and high-volume Twilio numbers receiving burst SMS can trigger this limit, causing Discord to return a 429 Too Many Requests response and drop the notification. Implement a rate limiter in your middleware that queues Discord posts and dispatches them at a maximum of 25 per minute, and use a separate webhook URL per notification type to spread the load across multiple rate-limit buckets. The Twilio Verify OTP expires after 10 minutes by default, and users who take longer than 10 minutes to enter the code receive a verification check response with status pending rather than approved, which your middleware may incorrectly treat as a successful verification. Always check that the VerificationCheck response status field equals the string approved rather than simply checking that the request succeeded, and return a clear error message to the Discord user when status is anything other than approved.

How to Get More from This Integration

Build a community SMS broadcast system where Discord server admins type a slash command with a message, your middleware looks up all verified members from a database table keyed by Discord user ID to phone number, and dispatches a Twilio SMS to each phone using a rate-limited queue to stay within Twilio's per-number throughput limits. Add Discord thread support to your SMS-to-Discord integration by using the Discord REST API to create a thread on the initial SMS notification message, then posting all subsequent SMS replies from the same phone number as messages within that thread using the thread_id parameter, keeping conversations organized without flooding the main channel. Extend the verification flow to collect and store the verified phone in Twilio Studio for future outbound use cases by creating a Twilio Address on the user's account after verification, enabling your team to reach verified Discord community members via SMS for announcements, events, or emergency alerts. Monitor your Discord integration health by posting a daily status message to a private Discord admin channel from a scheduled middleware job, including the count of SMS processed in the last 24 hours, any delivery failures logged, and the current Twilio balance, giving server admins visibility into the integration performance.

Conclusion

Twilio and Discord together add a real-world SMS communication layer to your community server, bridging the gap between phone-based outreach and your Discord-based operations. Reach out to Telphi Consulting to build the webhook forwarder, bot integration, or verification system your Discord server needs.

Share this article:
0 views

Ready to Transform Your Business Communications?

Get a free consultation with our VoIP experts and discover how we can help you save costs, improve efficiency, and scale your business.

Comments (0)

Join the discussion and share your thoughts (AI-moderated for quality)

Protected by AI moderation

Be the first to comment

No comments yet. Share your thoughts below.