Twilio and Microsoft Teams connect through Teams Incoming Webhooks and the Microsoft Graph API to post inbound SMS notifications into channels, alert on-call engineers when critical calls arrive, and log voice call summaries automatically without anyone leaving the Teams interface. This integration is built for Microsoft-centric organizations where the team lives in Teams all day and needs Twilio communication events to surface there rather than requiring a separate monitoring tool. The setup uses a Twilio inbound webhook to receive SMS or call events, a middleware layer to format the notification as a Teams Adaptive Card, and a Teams webhook endpoint to deliver the formatted alert to the correct channel.
What You Need Before You Start
Create a Teams Incoming Webhook in your target Teams channel by opening the channel, clicking the three-dot menu, selecting Connectors, finding Incoming Webhook in the connector list, clicking Configure, giving it a name like Twilio Alerts, uploading an optional icon, and clicking Create to generate the webhook URL. Copy the generated Teams webhook URL, which follows the pattern https://your-org.webhook.office.com/webhookb2/{guid}@{guid}/IncomingWebhook/{hash}/{guid}, and store it in your middleware environment variables. From Twilio, collect your Account SID, Auth Token, and the phone number whose events you want to forward to Teams, then configure that number's Messaging webhook URL in the Twilio Console to point to your middleware inbound handler. Your middleware needs a public HTTPS endpoint to receive Twilio POST payloads, and it should be able to construct and POST a valid Teams message card or Adaptive Card JSON payload to the Teams webhook URL.
Step-by-Step Integration Guide
In your middleware inbound handler, receive the Twilio POST payload and extract From, Body, MessageSid, and To from the URL-encoded form data, then construct a Teams Adaptive Card JSON payload with type set to message, attachments containing a contentType of application/vnd.microsoft.card.adaptive, and a content block with a body array containing TextBlock elements for the sender phone, message text, and timestamp. POST the Adaptive Card payload to the Teams Incoming Webhook URL with the Content-Type header set to application/json and the body containing your JSON payload, and check the response for a 1 response body which indicates success or an error message that indicates a malformed payload. Return a TwiML response from your middleware with an empty Response element so Twilio acknowledges the inbound event and does not retry the webhook delivery. For voice call notifications, configure your Twilio phone number's Voice webhook URL to a separate middleware handler that receives Twilio call events, extracts CallSid, From, To, and CallStatus, and posts a Teams card stating an inbound call arrived from the sender number along with the call status, enabling on-call teams to see missed calls in Teams without checking the Twilio Console.
Common Issues and How to Fix Them
Teams Incoming Webhooks return a 400 Bad Request response when the payload does not conform to the Microsoft Adaptive Card schema, which commonly occurs when required fields like type set to AdaptiveCard or version set to 1.4 are missing from the content JSON. Validate your Adaptive Card JSON using the Adaptive Cards Designer tool at adaptivecards.io/designer before deploying to production, and use the exact schema structure that Teams expects rather than the generic message card format. Teams webhook URLs contain long, complex path segments that can be accidentally truncated when copied from the Teams connector configuration page, causing all POST requests to return 404 or 403 errors. Always copy the webhook URL by right-clicking the URL in the Teams connector settings and selecting Copy Link rather than manually selecting the text, and verify the full URL is present in your environment variable by logging its length on startup. Teams channels set to Only owners can post will reject Incoming Webhook posts even from a configured connector, returning a 403 response without a clear error message. Check the channel posting permissions under the channel settings and ensure the permission is set to Everyone can post or at minimum that the webhook connector is explicitly allowed to post.
How to Get More from This Integration
Upgrade from Incoming Webhooks to the Microsoft Graph API by registering an Azure Active Directory app with the ChannelMessage.Send permission scope, obtaining a client credentials OAuth token from https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/token, and posting Twilio SMS notifications to a specific Teams channel via POST https://graph.microsoft.com/v1.0/teams/{teamId}/channels/{channelId}/messages with an Adaptive Card attachment, giving you more control including message threading and reply support. Build a two-way SMS responder by adding an Adaptive Card Action with an Action.ShowCard and Input.Text field to your Teams notification, allowing a Teams user to type a reply directly in the card and submit it to a Power Automate flow via an HTTP request, which then calls the Twilio Messages API to send the reply to the original sender. Route critical Twilio inbound SMS to Teams @mentions of on-call staff by resolving the on-call rotation from a SharePoint list or an external API and including a mention tag for the on-call user in the Teams message body using the Microsoft Graph mention format with the user's AAD object ID. Log Twilio voice call recordings to Teams by capturing the RecordingUrl from the Twilio StatusCallback, posting a Teams card with a clickable button linking to the recording URL, and storing the recording metadata in a SharePoint list for compliance and future search.
Conclusion
Twilio and Microsoft Teams together bring SMS and voice event visibility directly into the collaboration hub your organization uses every day, ensuring critical communications are never missed by anyone on the team. Get in touch with Telphi Consulting to build and deploy this integration for your Teams workspace.
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)
Be the first to comment
No comments yet. Share your thoughts below.