Integrations

ServiceNow Twilio SMS Integration Guide

intermediateBasic Authentication using Twilio Account SID as username and Auth Token as passwordTwilio

The ServiceNow Twilio SMS integration enables automated text message notifications directly from ServiceNow workflows, business rules, and notifications. This integration solves critical communication gaps by ensuring urgent incidents, task assignments, and approval requests reach stakeholders instantly via SMS when email notifications aren't sufficient. IT operations teams, service desk managers, and field service organizations commonly implement this integration to improve response times and stakeholder engagement. The integration supports bi-directional communication flows: outbound SMS notifications triggered by ServiceNow record events (incidents, changes, requests) and inbound SMS processing through Twilio webhooks that can create or update ServiceNow records. The primary automation pattern uses ServiceNow business rules or Flow Designer to trigger REST calls to Twilio's API, with the integration typically residing in the System Web Services and Integration Hub modules.

Prerequisites

  • ServiceNow Quebec or later instance with admin access
  • Integration Hub Professional license or IntegrationHub Installer role
  • Active Twilio account with SMS-enabled phone number
  • Twilio Account SID and Auth Token with SMS permissions
  • Network connectivity allowing outbound HTTPS calls to api.twilio.com
  • Inbound Actions plugin (com.glide.inbound_actions) activated if processing inbound SMS
  • Flow Designer or admin privileges to create business rules and notification records

Architecture Overview

The integration primarily uses ServiceNow's Integration Hub Twilio SMS spoke, which provides pre-built Actions for sending SMS messages, or alternatively RESTMessageV2 for custom implementations. Authentication is established using Twilio Account SID and Auth Token stored in a ServiceNow Connection & Credential Alias record, with credentials encrypted in the instance credential store. Data flows outbound from ServiceNow to Twilio via HTTPS REST API calls triggered by business rules, Flow Designer, or scheduled jobs, while inbound SMS messages are processed through Twilio webhooks calling ServiceNow Scripted REST APIs or Inbound Email Actions. No MID Server is required as the integration uses direct HTTPS communication between ServiceNow and Twilio's cloud API endpoints. Rate limiting follows Twilio's API limits of approximately 1 message per second per phone number, with SMS message costs applying per message sent, and ServiceNow Integration Hub transaction limits based on license tier.

Sourdough
Chrome Extension

Sourdough: ServiceNow Monitoring and Analytics

A Chrome extension for ServiceNow Admins and Developers with essential tools, analytics, graphs and monitoring features.

Instance HealthGraphs & ChartsAPI HealthDeveloper ToolsQuick SearchInstance Switcher
Add to Chrome

Free to install. Pro $5/month after a 14-day no-card trial.
Pro requires the ServiceNow admin role. Upgrade inside the extension.

Overview
Tasks
CMDB
API
Metrics
Monitor
Internals
Instance:sourdoughdev·Version:Yokohama
Instance StateONLINE
System StatusFully Operational
Session Timeout90 minutes
Logged-In Sessions2 (20 active)
Build Nameyokohama-12-18-2024_p1
IP Address10.159.128.43
Instance HealthHealth Score: 90%
🔥 5dSourdough (Chrome Plugin)Dark Mode

Implementation Steps

1

Configure Twilio account and retrieve API credentials

Log into your Twilio Console and navigate to Account > API keys & tokens to locate your Account SID and Auth Token. Ensure you have an active SMS-enabled phone number by going to Phone Numbers > Manage > Active numbers in the Twilio console. Note the phone number format including country code (e.g., +15551234567) as this will be your 'From' number for outbound messages. Verify your Twilio account has sufficient SMS credits and messaging service configuration if using advanced features. Record both the Account SID and Auth Token securely as these will be stored in ServiceNow's credential store.

2

Create Connection and Credential Alias records in ServiceNow

Navigate to Connections & Credentials > Credentials and click New to create a Basic Auth credential record. Set the Name field to 'Twilio SMS Credentials', enter your Twilio Account SID in the User name field, and your Auth Token in the Password field. Next, navigate to Connections & Credentials > Connection & Credential Aliases and create a new record with Name 'Twilio SMS Connection', Connection URL 'https://api.twilio.com', and select your newly created credential in the Credential field. Verify the credential test passes by using the Test Connection related link, which should return a successful authentication response.

3

Install and configure Integration Hub Twilio SMS spoke

Navigate to System Applications > All Available Applications > All and search for 'Twilio SMS' to locate the official ServiceNow Integration Hub spoke. Install the spoke and activate it by going to Process Automation > Flow Designer > Spokes and verifying the Twilio SMS spoke appears as Active. The spoke provides Actions including 'Send SMS Message' and 'Send MMS Message' that can be used in Flow Designer workflows. Configure the spoke's connection by editing the spoke record and associating it with your Twilio Connection & Credential Alias created in the previous step. Test the spoke configuration by creating a simple Flow Designer flow with the Send SMS Message action.

4

Create RESTMessageV2 record for direct API integration

Navigate to System Web Services > Outbound > REST Message and create a new record named 'Twilio SMS API'. Set the Endpoint to 'https://api.twilio.com/2010-04-01/Accounts/${account_sid}/Messages.json' and Authentication type to 'Basic'. Create an HTTP Method record with HTTP method 'POST' and name 'sendSMS', then add HTTP Headers for Content-Type: 'application/x-www-form-urlencoded' and Accept: 'application/json'. Configure the authentication to use your Connection & Credential Alias, ensuring the variable substitution for account_sid is properly configured. Test the REST Message using the Test related link with sample To, From, and Body parameters formatted as URL-encoded form data.

ServiceNow Script
// REST Message HTTP Method content (in HTTP Request tab)
To=${to_number}&From=${from_number}&Body=${message_body}

// Variable substitutions needed:
// ${account_sid} - Your Twilio Account SID
// ${to_number} - Destination phone number
// ${from_number} - Your Twilio phone number
// ${message_body} - SMS message text
5

Build SMS notification business rule for incident management

Navigate to System Definition > Business Rules and create a new rule named 'Incident SMS Notification' on the Incident table. Set the rule to trigger 'after' insert and update operations with conditions checking for high-priority incidents or specific assignment group changes. In the Advanced tab, enable the 'Advanced' checkbox and write a script that instantiates your Twilio REST Message, populates the required variables, and executes the HTTP request. Include error handling to log failed SMS attempts and consider adding logic to prevent duplicate notifications. Test the business rule by creating or updating an incident record that matches your trigger conditions and verify the SMS is received.

ServiceNow Script
(function executeRule(current, previous) {
    try {
        var restMessage = new sn_ws.RESTMessageV2('Twilio SMS API', 'sendSMS');
        restMessage.setStringParameterNoEscape('account_sid', gs.getProperty('twilio.account_sid'));
        restMessage.setStringParameterNoEscape('to_number', current.caller_id.mobile_phone);
        restMessage.setStringParameterNoEscape('from_number', gs.getProperty('twilio.from_number'));
        restMessage.setStringParameterNoEscape('message_body', 'Incident ' + current.number + ' assigned to you. Priority: ' + current.priority.getDisplayValue());
        
        var response = restMessage.execute();
        if (response.getStatusCode() != 201) {
            gs.error('Twilio SMS failed: ' + response.getBody());
        } else {
            gs.info('SMS sent successfully for incident ' + current.number);
        }
    } catch (ex) {
        gs.error('Error sending SMS: ' + ex.getMessage());
    }
})(current, previous);
6

Configure Flow Designer workflow for multi-step SMS automation

Navigate to Process Automation > Flow Designer and create a new flow triggered by 'Record Created or Updated' on your desired table (e.g., Incident). Add trigger conditions to filter for specific scenarios like priority 1 incidents or when assignment group changes. Drag the Twilio SMS spoke's 'Send SMS Message' action into your flow and configure the connection to use your credential alias. Map flow variables to the SMS fields: To (recipient phone), From (your Twilio number), and Body (dynamic message using incident details). Add error handling using conditional flows to capture failed SMS attempts and create follow-up actions. Test the flow using the Test button and verify SMS delivery and proper error handling.

7

Set up inbound SMS processing with Scripted REST API

Navigate to System Web Services > Scripted Web Services > Scripted REST APIs and create a new API named 'Twilio Inbound SMS'. Create a resource with HTTP method POST and relative path '/webhook' to handle Twilio's webhook calls. In the processing script, parse the incoming form parameters (From, Body, MessageSid) and implement logic to create or update ServiceNow records based on SMS content. Configure authentication as needed and ensure the script returns appropriate HTTP status codes to Twilio. The endpoint URL will be 'https://yourinstance.service-now.com/api/x_yourscope_app/twilio_inbound_sms/webhook' which you'll configure in Twilio's webhook settings. Test the endpoint using Twilio's webhook testing tools or a REST client with sample webhook payloads.

ServiceNow Script
(function process(request, response) {
    try {
        var requestBody = request.body.data;
        var fromNumber = requestBody.From;
        var messageBody = requestBody.Body;
        var messageSid = requestBody.MessageSid;
        
        // Parse message for incident number pattern
        var incidentMatch = messageBody.match(/INC\d{7}/);
        if (incidentMatch) {
            var incidentGR = new GlideRecord('incident');
            if (incidentGR.get('number', incidentMatch[0])) {
                // Add work note with SMS reply
                incidentGR.work_notes = 'SMS Reply from ' + fromNumber + ': ' + messageBody;
                incidentGR.update();
                
                response.setStatus(200);
                response.setBody('SMS processed successfully');
            }
        }
    } catch (ex) {
        gs.error('Inbound SMS processing error: ' + ex.getMessage());
        response.setStatus(500);
    }
})(request, response);
8

Configure Twilio webhook and test end-to-end integration

In your Twilio Console, navigate to Phone Numbers > Manage > Active Numbers and select your SMS-enabled number. Configure the webhook URL for incoming messages to point to your ServiceNow Scripted REST API endpoint with HTTP POST method. Set up webhook authentication if required and configure the webhook to send form-encoded data. Test the complete integration by sending an SMS to your Twilio number and verifying it creates the expected record or update in ServiceNow. Monitor System Logs > All for any processing errors and use Twilio's webhook debugging tools to troubleshoot failed webhook deliveries. Verify both outbound SMS notifications and inbound SMS processing work correctly with real test scenarios.

Common Use Cases

High-priority incident notifications to on-call engineers

Automatically send SMS alerts when Priority 1 or Priority 2 incidents are created or escalated, ensuring immediate notification even when email isn't monitored. The integration triggers from incident business rules and includes incident number, brief description, and assignment details. This use case significantly reduces mean time to response for critical issues and ensures 24/7 coverage effectiveness. SMS notifications bypass email filtering and provide instant mobile device alerts for faster incident response.

Change approval request notifications to change advisory board members

Send SMS notifications to change approval board members when emergency or high-risk changes require immediate approval outside business hours. The workflow triggers when change requests with specific risk levels or emergency flags are submitted for approval. Messages include change number, implementation window, risk level, and direct links to approve or reject via ServiceNow mobile app. This ensures critical change approvals don't delay due to unmonitored email during off-hours or weekends.

Field service technician task assignments and updates

Notify field service technicians via SMS when new work orders are assigned, location details change, or customer contact information is updated. The integration sends task details, customer location, estimated duration, and special instructions directly to technicians' mobile devices. Technicians can reply via SMS to confirm receipt, request reschedule, or provide status updates that automatically create work notes in ServiceNow. This improves field workforce coordination and reduces coordination phone calls between dispatch and field teams.

Service outage notifications to affected user groups

Automatically notify specific user groups or departments via SMS when service outages or planned maintenance windows are declared that affect their business operations. The system identifies affected users based on CMDB relationships and sends targeted notifications with outage details, expected resolution time, and status page links. Users receive follow-up SMS notifications when services are restored, maintaining transparent communication during business-impacting events. This reduces help desk call volume and proactively manages user expectations during service disruptions.

Two-way SMS for simple approval workflows

Enable managers and approvers to respond to approval requests via SMS with simple 'APPROVE' or 'REJECT' keywords along with the approval record number. The inbound SMS processing identifies the approval context, validates the sender's authority, and automatically processes the approval decision in ServiceNow. This streamlines approval processes for time-sensitive requests like emergency access, overtime authorization, or urgent purchase requisitions. The integration includes confirmation SMS replies and audit trail creation for compliance requirements.

Troubleshooting

HTTP 401 Unauthorized error when sending SMS through REST Message

First, verify your Twilio Account SID and Auth Token are correctly stored in the ServiceNow Credential record by testing the Connection & Credential Alias. Check System Logs > Outbound HTTP Requests for the actual authentication headers being sent and compare with Twilio's expected Basic Auth format. Ensure the Account SID variable substitution in your REST Message endpoint URL matches exactly with your credential username field. If using Flow Designer, verify the connection configuration in the Twilio SMS spoke is pointing to the correct credential alias and test the connection from the spoke configuration page.

SMS messages not being delivered despite successful HTTP 201 response

Check your Twilio Console logs under Monitor > Logs > Errors for message delivery failures, which often indicate invalid phone number formats or carrier restrictions. Verify the 'From' phone number in your SMS requests matches exactly with your purchased Twilio phone number including country code formatting. Review Twilio's messaging logs for delivery status and error codes, as messages may be accepted by the API but rejected by carriers due to content filtering or number validation issues. Ensure recipient phone numbers are in E.164 format (+1234567890) and consider implementing delivery status callbacks in Twilio to track message delivery confirmation.

Inbound SMS webhook receiving data but not processing correctly in ServiceNow

Enable debugging in your Scripted REST API by adding gs.info() statements to log incoming webhook payloads and verify Twilio is sending expected form parameters (From, Body, MessageSid). Check System Logs > All for JavaScript errors in your webhook processing script and ensure proper error handling is implemented. Verify the webhook endpoint URL in Twilio Console exactly matches your ServiceNow Scripted REST API path and confirm HTTP method is set to POST. Test the endpoint manually using a REST client with sample Twilio webhook payload structure to isolate processing logic issues from Twilio webhook delivery.

Business rule triggering multiple duplicate SMS messages

Add condition logic to your business rule to prevent duplicate triggers, such as checking if specific fields have actually changed using current.field.changes() methods. Implement a custom field or state tracking to mark records as already having SMS notifications sent and include this in your business rule conditions. Consider using Flow Designer instead of business rules for complex SMS logic as it provides better duplicate prevention and error handling capabilities. Review your business rule trigger conditions and timing (before/after, insert/update) to ensure they align with your notification requirements and don't create recursive triggers.

Integration Hub Twilio SMS spoke actions failing with connection timeouts

Verify your ServiceNow instance can reach api.twilio.com by testing the connection from System Diagnostics > Network Utilities or checking with your network team about firewall restrictions. Review Integration Hub transaction logs under Process Automation > Executions for specific timeout error details and increase timeout values if necessary. Check if a MID Server is inadvertently being used for the connection and switch to direct cloud-to-cloud communication if possible. Monitor Twilio's API status page for service interruptions and implement retry logic in your flows to handle temporary API unavailability gracefully.

SMS message content being truncated or displaying encoding issues

Ensure your message body variables are properly encoded and don't exceed SMS length limits of 160 characters for GSM encoding or 70 characters for Unicode content. Use the setStringParameterNoEscape() method in RESTMessageV2 to prevent double-encoding of special characters and review message content for unsupported characters. Implement message length validation in your business rules or flows and consider splitting long messages into multiple SMS or switching to MMS for longer content. Test message content with various special characters and international characters to ensure proper encoding through the entire message delivery chain.

Pro Tips

  • Implement SMS message templating using ServiceNow's Template Management (sys_template) records to maintain consistent message formatting and enable non-technical users to modify SMS content without code changes. Store message templates with variable placeholders and use GlideTemplate API in your business rules to populate dynamic content, improving maintainability and compliance with messaging standards.
  • Create a custom SMS tracking table to log all outbound and inbound SMS activity with fields for message content, delivery status, costs, and response tracking. This provides audit trails, enables SMS analytics reporting, and helps optimize messaging costs by identifying high-volume scenarios that might benefit from alternative communication channels or message consolidation strategies.
  • Use ServiceNow's Notification framework combined with custom notification devices to leverage existing notification conditions and user preferences while routing messages through Twilio. This approach allows users to set SMS preferences, quiet hours, and escalation rules while maintaining centralized notification management and reducing custom code maintenance overhead.
  • Implement SMS rate limiting and cost controls by creating custom application properties for daily/monthly SMS limits per user or globally, and add validation logic in your SMS sending code to prevent runaway messaging costs. Consider implementing approval workflows for bulk SMS operations and monitoring Integration Hub transaction usage to optimize licensing costs.
  • Set up bidirectional SMS conversation threading by storing SMS conversation state in custom tables and implementing keyword-based command processing for common actions like incident status updates, approval responses, or information requests. This creates more sophisticated SMS interfaces that reduce the need for users to access ServiceNow directly while maintaining proper audit trails and security validation.
  • Configure Twilio webhooks to include delivery status callbacks and implement ServiceNow webhook handlers to track message delivery, read receipts, and delivery failures. Store this status information in your SMS tracking system to enable retry logic for failed messages, generate delivery reports, and optimize messaging strategies based on actual delivery success rates.

Known Limitations

  • Twilio SMS API has rate limits of approximately 1 message per second per phone number, which may require message queuing or delay mechanisms for high-volume SMS scenarios like mass notifications during major incidents. ServiceNow Integration Hub licensing also imposes transaction limits that count against your subscription when using the official Twilio spoke for SMS operations.
  • SMS message length is limited to 160 characters for standard GSM encoding or 70 characters for Unicode content, requiring message truncation or splitting logic for longer notifications. MMS support is available but requires additional Twilio configuration and higher per-message costs, and not all mobile carriers guarantee MMS delivery reliability.
  • Inbound SMS processing requires exposing ServiceNow endpoints to Twilio webhooks, which may require firewall rule changes and careful security consideration for authentication and input validation. Webhook delivery failures can result in lost inbound messages, as Twilio has limited retry mechanisms compared to email-based inbound processing systems.
  • SMS delivery is dependent on mobile carrier networks and international SMS routing, which can introduce delivery delays, higher costs for international numbers, and potential message filtering by carriers for suspected spam content. Delivery confirmations are not guaranteed and require additional webhook configuration to track message delivery status accurately.
  • Integration costs include both Twilio per-message charges (typically $0.0075-$0.04 per SMS depending on destination) and ServiceNow Integration Hub transaction consumption, making SMS integration more expensive than email notifications for high-volume scenarios. Budget planning should account for both platform costs and potential message volume growth over time.

Frequently Asked Questions

Can I use a single Twilio phone number for multiple ServiceNow instances or environments?

Yes, you can use one Twilio phone number across multiple ServiceNow instances, but you'll need separate webhook endpoints for inbound SMS processing in each environment. Configure different webhook URLs in Twilio for different message types or use message routing logic to direct inbound SMS to appropriate instances. Consider using Twilio's messaging services feature for more sophisticated routing and failover capabilities. Be aware that SMS conversation context may become unclear to users if multiple environments send messages from the same number without clear identification.

How do I handle SMS notifications for users without mobile phone numbers in their ServiceNow profiles?

Implement fallback notification logic in your business rules or flows that checks for mobile phone availability before attempting SMS, then routes to email or other notification channels when mobile numbers are missing. Create custom fields or notification preferences that allow users to specify preferred contact methods and backup options. Consider using ServiceNow's notification framework with multiple notification devices configured per user to automatically handle failover scenarios. You can also implement approval workflows that require mobile phone verification before enabling SMS notifications for security and deliverability purposes.

What's the difference between using the Integration Hub Twilio spoke versus creating custom RESTMessageV2 records?

The Integration Hub Twilio spoke provides pre-built, supported actions with standardized error handling, connection management, and upgrade compatibility, making it ideal for standard SMS sending scenarios. Custom RESTMessageV2 implementations offer more flexibility for advanced Twilio features, custom error handling, and integration with other Twilio APIs beyond SMS. The spoke consumes Integration Hub transactions while RESTMessageV2 uses standard platform capabilities without additional licensing implications. Choose the spoke for standard implementations and RESTMessageV2 when you need custom Twilio API functionality not available in the standard spoke actions.

How can I implement SMS message templates that business users can modify without developer access?

Use ServiceNow's Template Management (sys_template) feature to create SMS message templates with variable substitution that business users can edit through the standard template interface. Create custom application properties for common SMS message components and reference these in your SMS sending code to enable administrator customization. Implement a custom SMS template table with rich text fields and approval workflows for template changes, then use GlideTemplate API to process templates in your integration code. Consider using Flow Designer with template-based message building that allows process owners to modify message content through the visual interface without code changes.

Can inbound SMS replies automatically update incident status or trigger specific workflows in ServiceNow?

Yes, implement keyword-based SMS command processing in your inbound webhook handler that parses message content for specific commands like 'CLOSE INC1234567' or 'APPROVE REQ0012345' and executes appropriate ServiceNow updates. Create a command dictionary table that maps SMS keywords to ServiceNow actions and validate sender authorization against user records before processing commands. Use Flow Designer or business rules triggered by inbound SMS processing to handle complex workflow scenarios like state changes, approvals, or task assignments. Implement confirmation SMS replies to acknowledge successful command processing and error messages for invalid commands or authorization failures.

What security considerations should I implement for SMS integrations with sensitive ServiceNow data?

Implement sender validation in inbound SMS processing by matching phone numbers against verified user mobile phone fields and requiring additional authentication for sensitive operations. Use encrypted credential storage for Twilio API keys and implement IP allowlisting where possible to restrict webhook endpoints. Sanitize and validate all inbound SMS content to prevent injection attacks and implement rate limiting on webhook endpoints to prevent abuse. Consider implementing SMS-based two-factor authentication for high-privilege operations and audit all SMS interactions in custom tracking tables for compliance and security monitoring requirements.

How do I monitor SMS integration costs and implement budget controls to prevent unexpected charges?

Create custom monitoring dashboards that track SMS volume, costs, and delivery rates using data from your SMS tracking table combined with Twilio usage APIs for real-time cost visibility. Implement application properties for daily, weekly, and monthly SMS limits with validation logic in your sending code that prevents exceeding budget thresholds. Set up automated alerts when SMS usage approaches defined limits and consider implementing approval workflows for bulk SMS operations. Use ServiceNow's reporting capabilities to analyze SMS usage patterns by user, department, or use case to optimize messaging strategies and identify cost reduction opportunities while maintaining service quality.

Test Your Knowledge

Quick 3-question quiz — see how your ServiceNow skills stack up.

Question 1 of 3Performance

A list view on a table with millions of records is slow. Best fix?

Select an answer to continue