Integration Guide

How to Connect InstantDM with Twilio SMS (Step-by-Step Guide)

Learn how to connect InstantDM with Twilio to send SMS messages when Instagram DM leads are captured. Step-by-step guide for sending SMS follow-ups from Instagram interactions.

Meta Business Partner
30,000+ creators
$9.99/mo flat

Twilio is the leading cloud communications platform for SMS, voice, and messaging. Connecting InstantDM to Twilio lets you send SMS messages when someone interacts with your Instagram DM automations - send a text confirmation after capturing a lead, alert your sales team, or follow up with prospects on a second channel.


Why Connect InstantDM to Twilio?

  • Instant SMS delivery - reach leads on their phone within seconds of an Instagram interaction
  • Two-way SMS - receive replies and continue the conversation via text
  • Global reach - send SMS to 180+ countries
  • Programmable - full control over message content, timing, and logic
  • Reliable - Twilio handles carrier compliance, number formatting, and delivery

Common Use Cases

  • Send an SMS confirmation when someone shares their phone number via DM
  • Alert your sales team via SMS when a high-intent lead is captured
  • Send a discount code or link via text after an Instagram interaction
  • Follow up with leads who didn't open your email
  • Send appointment reminders after booking via DM

What You'll Need

Requirement Details
InstantDM account Trendsetter, Trendsetter Pro, or any Multi plan
Twilio account Free trial or paid account
InstantDM API key Found at Settings → API in your InstantDM dashboard
Twilio credentials Account SID, Auth Token, and a Twilio phone number

Method 1: Via Make.com

Step 1: Set Up the Webhook

Follow Steps 1-4 in the Make.com integration guide to create a webhook scenario.

Step 2: Add a Twilio Module

  1. After the webhook trigger, add a Filter: event equals flow_completed.
  2. Add a second Filter (or IF condition): data.response_variables.phone is not empty.
  3. Click "+" and search for Twilio.
  4. Select Send an SMS.
  5. Connect your Twilio account.

Step 3: Configure the SMS

Twilio Field Value
From Your Twilio phone number
To {{data.response_variables.phone}}
Body See message templates below

Message Templates

Lead confirmation:

Hi {{data.response_variables.full_name}}! Thanks for connecting on Instagram. We've sent the info you requested to {{data.response_variables.email}}. Reply STOP to opt out.

Sales team alert:

🎯 New Instagram lead: {{data.response_variables.full_name}} ({{data.response_variables.email}}). Interest: {{data.response_variables.interest}}. IG: @{{data.username}}

Discount code:

Hey {{data.response_variables.full_name}}! Here's your exclusive 15% off code: INSTA15. Shop now: https://yourstore.com/shop?ref=instagram. Reply STOP to opt out.

Step 4: Test and Activate

  1. Run once in Make.com.
  2. Trigger a test event from InstantDM.
  3. Check your phone - the SMS should arrive.
  4. Activate the scenario.

Method 2: Direct API Integration

Step 1: Get Your Twilio Credentials

  1. Sign up at twilio.com.
  2. From the Console dashboard, copy your Account SID and Auth Token.
  3. Get a Twilio phone number: Phone Numbers → Manage → Buy a number.

Step 2: Build a Webhook Receiver

const express = require('express');
const app = express();
app.use(express.json());

const TWILIO_SID = process.env.TWILIO_ACCOUNT_SID;
const TWILIO_AUTH = process.env.TWILIO_AUTH_TOKEN;
const TWILIO_FROM = '+1234567890'; // Your Twilio number

async function sendSMS(to, body) {
  const response = await fetch(
    `https://api.twilio.com/2010-04-01/Accounts/${TWILIO_SID}/Messages.json`,
    {
      method: 'POST',
      headers: {
        'Authorization': 'Basic ' + Buffer.from(`${TWILIO_SID}:${TWILIO_AUTH}`).toString('base64'),
        'Content-Type': 'application/x-www-form-urlencoded',
      },
      body: new URLSearchParams({
        From: TWILIO_FROM,
        To: to,
        Body: body,
      }),
    }
  );
  return response.json();
}

app.post('/instantdm-webhook', async (req, res) => {
  const { event, data } = req.body;
  
  if (event !== 'flow_completed') {
    return res.status(200).json({ status: 'skipped' });
  }
  
  const phone = data.response_variables?.phone;
  if (!phone) {
    return res.status(200).json({ status: 'skipped', reason: 'no phone number' });
  }
  
  try {
    const name = data.response_variables.full_name || 'there';
    const message = `Hi ${name}! Thanks for connecting on Instagram. We've sent the info you requested to your email. Reply STOP to opt out.`;
    
    const result = await sendSMS(phone, message);
    res.status(200).json({ status: 'sent', sid: result.sid });
  } catch (error) {
    res.status(500).json({ status: 'error', message: error.message });
  }
});

// Alert sales team for high-intent leads
app.post('/instantdm-webhook-alert', async (req, res) => {
  const { event, data } = req.body;
  
  if (event !== 'flow_completed') {
    return res.status(200).json({ status: 'skipped' });
  }
  
  const SALES_TEAM_NUMBER = '+1987654321';
  const name = data.response_variables?.full_name || data.username;
  const interest = data.response_variables?.interest || 'N/A';
  
  const alert = `🎯 New IG lead!\nName: ${name}\nEmail: ${data.response_variables?.email}\nInterest: ${interest}\nIG: @${data.username}`;
  
  await sendSMS(SALES_TEAM_NUMBER, alert);
  res.status(200).json({ status: 'alert_sent' });
});

app.listen(3000);

Phone Number Formatting

Twilio requires phone numbers in E.164 format (e.g., +1234567890). If your DM flow captures numbers in other formats, normalize them:

function normalizePhone(phone, defaultCountryCode = '+1') {
  // Remove spaces, dashes, parentheses
  let cleaned = phone.replace(/[\s\-\(\)]/g, '');
  
  // Add country code if missing
  if (!cleaned.startsWith('+')) {
    cleaned = defaultCountryCode + cleaned;
  }
  
  return cleaned;
}

Tip: In your InstantDM DM flow, ask for the phone number with a hint like "Include country code (e.g., +1 for US)" to get cleaner data.


Compliance and Opt-Out

SMS marketing has strict compliance requirements:

  • Always include opt-out language - add "Reply STOP to opt out" to every marketing message
  • Honor opt-outs - Twilio automatically handles STOP/UNSUBSCRIBE replies
  • Get consent - your DM flow should include language like "By sharing your phone number, you agree to receive text messages from us"
  • Identify yourself - include your brand name in the message
  • Respect quiet hours - avoid sending SMS late at night

Troubleshooting

Issue Solution
SMS not delivered Check the phone number format (must be E.164). Verify your Twilio number is active. Check Twilio's message logs for error codes.
Error 21211 (invalid number) The "To" number is not a valid phone number. Normalize the format.
Error 21608 (unverified number) On Twilio trial accounts, you can only send to verified numbers. Upgrade to a paid account for production.
Error 21610 (blocked) The recipient has opted out (replied STOP). You cannot send to them.
Messages delayed SMS delivery depends on carriers. Most messages arrive within seconds, but some carriers may delay.
High costs Twilio charges per message segment (160 characters for SMS). Keep messages concise. Use short URLs.

Frequently Asked Questions

How much does Twilio SMS cost?

Twilio charges per message: ~$0.0079/message for US numbers. International rates vary. A Twilio phone number costs ~$1.15/month. The free trial includes $15 in credit.

Can I send MMS (images) via Twilio?

Yes. Twilio supports MMS in the US and Canada. Add a MediaUrl parameter to include an image. This is useful for sending product images or branded graphics.

Can I receive SMS replies and route them back to InstantDM?

Twilio can forward incoming SMS to a webhook. You could build a bridge that receives SMS replies and sends them as DMs via the InstantDM API, but this requires custom development.

Should I use Twilio or Brevo for SMS?

Twilio gives you more control and works globally. Brevo is simpler if you're already using it for email. For dedicated SMS with advanced features (two-way messaging, programmable logic), use Twilio. For basic SMS alongside email campaigns, Brevo is easier.


What's Next

Ready to Automate Your Instagram DMs?

Join 30,000+ creators and brands using InstantDM today.

Start Your Free Trial

No credit card required. Setup in under 15 minutes.