NotiGrid
Channels

Twilio Integration

Set up Twilio for SMS and voice notifications

Twilio Integration

Send SMS messages and voice calls through Twilio with NotiGrid.

Overview

Twilio provides reliable SMS and voice communication APIs that integrate seamlessly with NotiGrid.

Supported Features:

  • SMS messages
  • MMS (multimedia messages)
  • Voice calls
  • WhatsApp Business messages (if enabled on your Twilio account)

Prerequisites

  • Twilio account (Sign up here)
  • Phone number from Twilio
  • NotiGrid account

Setup Instructions

1. Create Twilio Account

  1. Go to twilio.com/try-twilio
  2. Sign up for a free account
  3. Complete phone verification
  4. Answer the onboarding questions

2. Get Your Account Credentials

  1. Log in to Twilio Console
  2. From the dashboard, locate:
    • Account SID - Your unique account identifier
    • Auth Token - Click "Show" to reveal (keep this secret!)
  3. Copy both values - you'll need them for NotiGrid

3. Get a Phone Number

Option A: Trial Phone Number (Free)

Your trial account comes with a free number:

  1. Go to Phone Numbers → Manage → Active numbers
  2. You'll see your trial number listed

Trial Limitations:

  • Can only send to verified phone numbers
  • Messages include "Sent from your Twilio trial account" prefix
  • Limited features
  1. Go to Phone Numbers → Manage → Buy a number
  2. Select your country
  3. Choose number capabilities:
    • SMS - For text messages
    • MMS - For multimedia messages
    • Voice - For voice calls
  4. Search and select a number
  5. Click Buy (~$1-2/month depending on country)

4. Verify Phone Numbers (Trial Only)

If using a trial account, verify recipient numbers:

  1. Go to Phone Numbers → Manage → Verified Caller IDs
  2. Click + Add a new number
  3. Enter the phone number
  4. Choose verification method (SMS or call)
  5. Enter the verification code

5. Configure in NotiGrid

  1. Log in to NotiGrid dashboard
  2. Navigate to Channels → SMS → Twilio
  3. Click Add Twilio Account
  4. Enter your credentials:
    • Account Name: "Production Twilio" (or any name)
    • Account SID: From step 2
    • Auth Token: From step 2
    • From Phone Number: Your Twilio number (e.g., +1234567890)
  5. Click Save & Test Connection

Sending Notifications

SMS Messages

Via NotiGrid Dashboard

  1. Go to Notifications → Send
  2. Select SMS channel
  3. Choose Twilio as provider
  4. Enter recipient number (E.164 format: +1234567890)
  5. Type your message
  6. Click Send

Via API

curl -X POST https://api.notigrid.com/v1/notifications \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "channel": "sms",
    "to": "+1234567890",
    "body": "Your verification code is: 123456"
  }'

MMS Messages (With Media)

curl -X POST https://api.notigrid.com/v1/notifications \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "channel": "sms",
    "to": "+1234567890",
    "body": "Check out our new product!",
    "metadata": {
      "mediaUrl": "https://example.com/image.jpg"
    }
  }'

Voice Calls

curl -X POST https://api.notigrid.com/v1/notifications \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "channel": "voice",
    "to": "+1234567890",
    "body": "Hello! This is an automated call from NotiGrid.",
    "metadata": {
      "voice": "alice",
      "language": "en-US"
    }
  }'

Message Templates

SMS Template

{
  "name": "verification-code",
  "channel": "sms",
  "body": "Your {{app_name}} verification code is: {{code}}. This code expires in {{expires_in}} minutes."
}

Usage:

curl -X POST https://api.notigrid.com/v1/notifications \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "template": "verification-code",
    "to": "+1234567890",
    "data": {
      "app_name": "NotiGrid",
      "code": "123456",
      "expires_in": "10"
    }
  }'

Order Status Template

{
  "name": "order-shipped",
  "channel": "sms",
  "body": "Great news! Your order #{{order_id}} has shipped. Track it here: {{tracking_url}}"
}

Advanced Features

Delivery Status Callbacks

Get notified when messages are delivered:

  1. In NotiGrid dashboard, go to Settings → Webhooks
  2. Add your webhook URL for delivery status
  3. NotiGrid will send POST requests with delivery updates:
{
  "event": "message.delivered",
  "messageId": "msg_123456",
  "to": "+1234567890",
  "status": "delivered",
  "timestamp": "2025-01-16T10:30:00Z"
}

Message Segments

SMS messages are charged per segment:

  • Standard (GSM-7): 160 characters per segment
  • Unicode: 70 characters per segment
  • Concatenated: Overhead reduces per-segment count

Example:

  • 150 characters = 1 segment
  • 165 characters = 2 segments
  • 320 characters = 3 segments

Tips to reduce segments:

  • Avoid emojis (use Unicode)
  • Avoid special characters when possible
  • Use URL shorteners for long links

Sender ID (Alpha Sender)

Available in some countries (UK, parts of Europe, Asia):

curl -X POST https://api.notigrid.com/v1/notifications \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "channel": "sms",
    "to": "+447700900000",
    "body": "Hello from MyBrand!",
    "metadata": {
      "from": "MyBrand"
    }
  }'

Note: Not supported in US/Canada.

Short Codes

For high-volume SMS (requires separate application):

  1. Apply for short code through Twilio
  2. Complete carrier approval (4-12 weeks)
  3. Configure in NotiGrid
  4. Use for promotional campaigns

Phone Number Types

Long Code (Standard)

  • Format: Regular 10-digit number (+1234567890)
  • Use case: P2P messaging, transactional SMS
  • Throughput: 1 message per second
  • Cost: ~$1-2/month

Toll-Free Numbers

  • Format: +1 (8XX) XXX-XXXX
  • Use case: Business messaging, customer support
  • Throughput: Higher than long code
  • Cost: ~$2-5/month
  • Verification required for A2P messaging

Short Codes

  • Format: 5-6 digits (e.g., 12345)
  • Use case: Marketing, high-volume
  • Throughput: Up to 100 messages per second
  • Cost: ~$1,000-1,500/month

WhatsApp Business API

If you have WhatsApp Business enabled:

Setup

  1. Apply for WhatsApp Business access through Twilio
  2. Get your WhatsApp number approved
  3. Configure in NotiGrid

Send WhatsApp Message

curl -X POST https://api.notigrid.com/v1/notifications \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "channel": "whatsapp",
    "to": "+1234567890",
    "body": "Hello from NotiGrid!",
    "metadata": {
      "from": "whatsapp:+1234567890"
    }
  }'

Rate Limits & Throughput

Default Limits

  • Long code: 1 msg/second
  • Toll-free: 3 msg/second (after verification: higher)
  • Short code: Up to 100 msg/second

Increase Limits

  1. Contact Twilio support
  2. Provide use case details
  3. Request higher throughput
  4. May require additional verification

Pricing

SMS Pricing (US, as of 2025)

  • Outbound: $0.0079 per message segment
  • Inbound: $0.0079 per message segment
  • MMS: $0.02 per message

International SMS

Voice Pricing (US)

  • Outbound calls: $0.013/minute
  • Inbound calls: $0.0085/minute

Cost Estimation

  • 10,000 SMS/month ≈ $79
  • 100,000 SMS/month ≈ $790
  • Add phone number cost (~$1/month)

Best Practices

Compliance

  1. Obtain consent - Get explicit opt-in before sending
  2. Include opt-out - Always provide "Reply STOP to unsubscribe"
  3. Honor opt-outs - Process STOP requests immediately
  4. Time restrictions - Don't send 9PM - 8AM local time
  5. Identify yourself - Make sender clear in message

Message Quality

  1. Keep it concise - Aim for under 160 characters
  2. Use clear CTAs - Make actions obvious
  3. Personalize - Use recipient's name when appropriate
  4. Provide value - Only send useful, timely information
  5. Test thoroughly - Send test messages before campaigns

Deliverability

  1. Use registered numbers - Register toll-free numbers for A2P
  2. Avoid spam triggers - Don't use all caps, excessive punctuation
  3. Monitor metrics - Track delivery and conversion rates
  4. Maintain clean lists - Remove invalid/inactive numbers
  5. Segment audience - Send relevant content to each group

Monitoring & Analytics

Key Metrics

Track in NotiGrid dashboard:

  • Sent - Total messages sent
  • Delivered - Successfully delivered
  • Failed - Delivery failures
  • Delivery rate - Percentage delivered
  • Cost - Total spend

Error Codes

Common Twilio error codes:

  • 30003 - Unreachable destination
  • 30004 - Message blocked
  • 30005 - Unknown destination
  • 30006 - Landline or unreachable carrier
  • 30007 - Message filtered (spam)
  • 21211 - Invalid phone number

Troubleshooting

Messages Not Sending

  1. Check phone format - Must be E.164 (+1234567890)
  2. Verify number - On trial, recipient must be verified
  3. Check balance - Ensure Twilio account has credit
  4. Review logs - Check Twilio console for errors
  5. Test connection - Use NotiGrid test button

High Failure Rate

  1. Validate numbers - Use phone validation API
  2. Remove landlines - Can't receive SMS
  3. Check carrier blocks - Some carriers filter messages
  4. Review content - Avoid spam-like content
  5. Register numbers - Complete A2P registration for toll-free

Messages Going to Spam

  1. Register your number - Complete carrier registration
  2. Use verified sender - Register your brand
  3. Avoid spam triggers - No "FREE", "CLICK HERE", etc.
  4. Include opt-out - Always provide unsubscribe option
  5. Maintain good practices - Low complaint rates

Security

  1. Secure credentials - Never expose Auth Token
  2. Use environment variables - Don't hardcode credentials
  3. Rotate tokens - Periodically rotate auth tokens
  4. Enable 2FA - Secure your Twilio account
  5. Monitor usage - Set up alerts for unusual activity
  6. IP whitelisting - Restrict API access (if possible)

Compliance & Regulations

United States

  • TCPA - Telephone Consumer Protection Act
  • CAN-SPAM - Email/SMS marketing rules
  • CTIA - Carrier guidelines

Europe

  • GDPR - Data protection requirements
  • Privacy and Electronic Communications Directive

Global

  • Check local regulations for each destination country
  • Maintain consent records
  • Honor do-not-call lists

Support Resources