Integration Guide

How to Deploy InstantDM Webhooks on Vercel (Serverless)

Learn how to process InstantDM webhook events using Vercel serverless functions. Zero-config deployment for Instagram DM automation.

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

Vercel makes serverless deployment dead simple - push code to GitHub and get a live URL. This guide shows you how to deploy an InstantDM webhook handler on Vercel.


Why Vercel?

  • Zero config - push to GitHub, get a URL
  • Free tier - generous for webhook processing
  • Automatic HTTPS - no SSL setup needed
  • Edge network - fast response times globally
  • Environment variables - secure secret management

Setup

Step 1: Create the Project

mkdir instantdm-vercel && cd instantdm-vercel
npm init -y

Step 2: Create the Webhook Handler

// api/webhook.js
export default async function handler(req, res) {
  if (req.method !== 'POST') {
    return res.status(405).json({ error: 'Method not allowed' });
  }
  
  const { event, timestamp, data } = req.body;
  
  console.log(`Event: ${event} from @${data.username}`);
  
  if (event === 'flow_completed') {
    const name = data.response_variables?.full_name || 'there';
    
    await fetch('https://api.instantdm.com/api-webhook', {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${process.env.INSTANTDM_API_KEY}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        action: 'send_message',
        type: 'text',
        recipient_id: data.instagram_user_id,
        message: `Thanks ${name}! We'll follow up shortly.`,
      }),
    });
  }
  
  res.status(200).json({ status: 'ok' });
}

Step 3: Deploy

npx vercel

Or push to GitHub and connect the repo in the Vercel dashboard.

Step 4: Set Environment Variables

In Vercel Dashboard → Settings → Environment Variables:

  • INSTANTDM_API_KEY = your API key

Step 5: Configure InstantDM

Paste your Vercel URL + /api/webhook into InstantDM Settings → API → Webhook URL.

Example: https://your-project.vercel.app/api/webhook


Troubleshooting

Issue Solution
404 on webhook URL Ensure the file is at api/webhook.js (Vercel uses file-based routing).
Environment variable undefined Add it in Vercel Dashboard, not in .env. Redeploy after adding.
Function timeout Vercel Hobby plan has a 10-second limit. Upgrade to Pro for 60 seconds.

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.