WooCommerce is the most popular e-commerce platform for WordPress. Connecting InstantDM to WooCommerce lets you sync Instagram DM leads as customers, send product recommendations, and generate unique coupon codes - all triggered by Instagram interactions.
Why Connect InstantDM to WooCommerce?
- Sync leads as customers - create WooCommerce customer records from DM flow data
- Generate coupons - create unique discount codes for Instagram leads
- Product recommendations - send product info based on DM flow answers
- Order notifications - DM customers about order status changes
- WordPress ecosystem - leverage the full WordPress plugin ecosystem
Common Use Cases
- Create a WooCommerce customer when someone completes a DM lead capture flow
- Send a unique coupon code via DM after someone comments on a product post
- Recommend products based on quiz answers in a DM flow
- Notify customers via DM when their order ships
What You'll Need
| Requirement | Details |
|---|---|
| InstantDM account | Trendsetter, Trendsetter Pro, or any Multi plan |
| WooCommerce store | WordPress with WooCommerce plugin |
| InstantDM API key | Found at Settings → API in your InstantDM dashboard |
| WooCommerce API keys | Found at WooCommerce → Settings → Advanced → REST API |
Step 1: Generate WooCommerce API Keys
- In WordPress Admin, go to WooCommerce → Settings → Advanced → REST API.
- Click Add key.
- Set:
- Description:
InstantDM Integration - User: Select an admin user
- Permissions: Read/Write
- Description:
- Click Generate API key.
- Copy the Consumer Key and Consumer Secret.
Step 2: Build a Webhook Receiver
const express = require('express');
const app = express();
app.use(express.json());
const WC_URL = 'https://yourstore.com';
const WC_KEY = process.env.WC_CONSUMER_KEY;
const WC_SECRET = process.env.WC_CONSUMER_SECRET;
async function wcFetch(endpoint, method = 'GET', body = null) {
const url = new URL(`${WC_URL}/wp-json/wc/v3/${endpoint}`);
url.searchParams.set('consumer_key', WC_KEY);
url.searchParams.set('consumer_secret', WC_SECRET);
const response = await fetch(url.toString(), {
method,
headers: { 'Content-Type': 'application/json' },
body: body ? JSON.stringify(body) : null,
});
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 email = data.response_variables?.email;
if (!email) return res.status(200).json({ status: 'skipped' });
try {
// Check if customer exists
const existing = await wcFetch(`customers?email=${encodeURIComponent(email)}`);
if (existing.length > 0) {
// Update existing customer
await wcFetch(`customers/${existing[0].id}`, 'PUT', {
meta_data: [
{ key: 'instagram_username', value: data.username },
{ key: 'instagram_flow', value: data.flow_name },
{ key: 'instagram_interest', value: data.response_variables?.interest || '' },
],
});
res.status(200).json({ status: 'updated', customerId: existing[0].id });
} else {
// Create new customer
const nameParts = (data.response_variables?.full_name || data.username).split(' ');
const customer = await wcFetch('customers', 'POST', {
email: email,
first_name: nameParts[0] || '',
last_name: nameParts.slice(1).join(' ') || '',
billing: {
email: email,
phone: data.response_variables?.phone || '',
first_name: nameParts[0] || '',
last_name: nameParts.slice(1).join(' ') || '',
},
meta_data: [
{ key: 'instagram_username', value: data.username },
{ key: 'instagram_flow', value: data.flow_name },
{ key: 'instagram_interest', value: data.response_variables?.interest || '' },
{ key: 'lead_source', value: 'Instagram DM' },
],
});
res.status(200).json({ status: 'created', customerId: customer.id });
}
} catch (error) {
res.status(500).json({ status: 'error', message: error.message });
}
});
app.listen(3000);
Generate Unique Coupon Codes
async function createCoupon(discountPercent = 15) {
const code = `INSTA-${Date.now().toString(36).toUpperCase()}`;
const coupon = await wcFetch('coupons', 'POST', {
code: code,
discount_type: 'percent',
amount: String(discountPercent),
individual_use: true,
usage_limit: 1,
date_expires: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000).toISOString(),
description: 'Instagram DM lead coupon',
});
return coupon.code;
}
Send via InstantDM:
const couponCode = await createCoupon(15);
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: `🎉 Here's your exclusive 15% off code: ${couponCode}\n\nValid for 7 days. Shop now: ${WC_URL}`,
}),
});
Via Make.com
- Set up the webhook per the Make.com guide.
- Add WooCommerce → Create a Customer module.
- Map fields from the webhook data.
- Add WooCommerce → Create a Coupon module for discount codes.
- Add HTTP Request to send the coupon via InstantDM API.
Troubleshooting
| Issue | Solution |
|---|---|
| WooCommerce API returning 401 | Verify consumer key and secret. Ensure the API keys have Read/Write permissions. |
| "Customer already exists" | Search by email first and update instead of creating. |
| Coupon not working at checkout | Check the coupon dates and usage limit. Ensure individual_use settings match your intent. |
| SSL errors | WooCommerce REST API requires HTTPS. Ensure your WordPress site has a valid SSL certificate. |
| Slow API responses | WooCommerce API can be slow on shared hosting. Consider caching or using a better hosting provider. |
Frequently Asked Questions
Does this work with WooCommerce on shared hosting?
Yes, but performance may be slower. The WooCommerce REST API works on any hosting that supports WordPress. For better performance, use managed WordPress hosting.
Can I use WooCommerce webhooks to trigger InstantDM DMs?
Yes. Go to WooCommerce → Settings → Advanced → Webhooks and create a webhook for order events. Point it at your server, which then calls the InstantDM API to send a DM.
How is this different from using Shopify with InstantDM?
The integration pattern is the same - webhook receiver, customer sync, coupon generation. WooCommerce uses REST API with consumer key/secret auth, while Shopify uses Admin API with access tokens. The business logic is identical.
What's Next
- Set up Stripe Payment Links for payment collection via DMs.
- Connect to Shopify if you're considering switching platforms.
- Read the Klaviyo guide for e-commerce email marketing.
- Build a Custom AI Agent for product recommendations.
- Explore the full API docs at instantdm.com/instagram-api-docs.