AI & Workflow Automation · Published · Updated · 1 min read

Automating Customer Support: Node.js WhatsApp and Email Alerts

By John Oruebi Eniekpo — Data Analyst, Business Intelligence Specialist & Full-Stack Web Developer

Automating Customer Support: Node.js WhatsApp and Email Alerts

Build a Node.js and Express webhook handler that routes incoming webform inquiries to WhatsApp and email alerts in near real-time.

Why Delayed Support Responses Cost Your Business

When potential clients submit inquiries on your website, your response speed directly impacts your conversion rate. Waiting hours to address a lead often results in lost opportunities. A manual triage process where team members check mailboxes or spreadsheets introduces a major bottleneck.

At YOLETECH, we frequently see businesses struggle to monitor webform submissions instantly. By automating notification routing, you can reduce notification delay to under 30 seconds instead of the usual 14 hour response lag.

You can solve this problem by building a lightweight automated alert pipeline. This system uses webhooks to receive new submissions, then immediately sends an on-call alert via WhatsApp and a detailed email to your support queue.

  • - -

The Automation Stack and Prerequisites

This pipeline is built on a serverless Node.js backend. To run this script, you must configure a server with Node.js installed, plus API accounts with Twilio (for WhatsApp alerts) and SendGrid (for emails).

First, initialize your project in a new directory and install the necessary dependencies:

bash
mkdir support-alerts && cd support-alerts
npm init -y
npm install express dotenv @sendgrid/mail twilio

Create a .env file in your root folder to securely store your API keys:

PORT=3000
TWILIO_ACCOUNT_SID=your_twilio_sid
TWILIO_AUTH_TOKEN=your_twilio_token
TWILIO_WHATSAPP_NUMBER=whatsapp:+14155238886
SUPPORT_AGENT_WHATSAPP=whatsapp:+225523467
SENDGRID_API_KEY=your_sendgrid_key
SENDER_EMAIL=alerts@yourdomain.com
SUPPORT_QUEUE_EMAIL=support@yourdomain.com

Step 1: Building the Webhook Receiver

This Express script acts as an HTTP POST endpoint. It parses incoming webhook payloads from your website's contact form, then handles alerting processes asynchronously. Create a file named server.js and paste this code:

require('dotenv').config();
const express = require('express');
const sgMail = require('@sendgrid/mail');
const twilio = require('twilio');

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

sgMail.setApiKey(process.env.SENDGRID_API_KEY);
const twilioClient = twilio(process.env.TWILIO_ACCOUNT_SID, process.env.TWILIO_AUTH_TOKEN);

async function sendWhatsAppAlert(name, message) {
  try {
    await twilioClient.messages.create({
      from: process.env.TWILIO_WHATSAPP_NUMBER,
      to: process.env.SUPPORT_AGENT_WHATSAPP,
      body: `New Web Lead: ${name} is requesting assistance. Message excerpt: "${message.substring(0, 60)}..."`
    });
    console.log('WhatsApp notification sent successfully.');
  } catch (error) {
    console.error('WhatsApp dispatch failure:', error.message);
  }
}

async function sendEmailNotification(name, email, message) {
  const mailPayload = {
    to: process.env.SUPPORT_QUEUE_EMAIL,
    from: process.env.SENDER_EMAIL,
    subject: `Urgent: New Support Lead from ${name}`,
    text: `You have received a new support inquiry.\n\nName: ${name}\nEmail: ${email}\n\nMessage:\n${message}`,
    html: `<p><strong>Name:</strong> ${name}</p><p><strong>Email:</strong> ${email}</p><p><strong>Message:</strong></p><p>${message}</p>`
  };

  try {
    await sgMail.send(mailPayload);
    console.log('Email notification sent successfully.');
  } catch (error) {
    console.error('Email dispatch failure:', error.message);
  }
}

app.post('/webhook/new-lead', async (req, res) => {
  const { name, email, message } = req.body;

  if (!name || !email || !message) {
    return res.status(400).json({ error: 'Missing required payload fields' });
  }

  res.status(202).json({ status: 'Processing alert sequence' });

  await Promise.all([
    sendWhatsAppAlert(name, message),
    sendEmailNotification(name, email, message)
  ]);
});

const PORT = process.env.PORT || 3000;
app.listen(PORT, () => console.log(`Automation server operational on port ${PORT}`));

Step 2: Testing Your Automation Pipeline

To run your automation server, run this command:

node server.js

You can simulate an incoming webhook submission by using curl in a separate terminal window:

curl -X POST http://localhost:3000/webhook/new-lead \
-H "Content-Type: application/json" \
-d '{"name": "Jane Doe", "email": "janedoe@example.com", "message": "I need help with a deployment issue."}'

If your API keys are correct, your agent's phone will instantly receive a WhatsApp notification, and your support email queue will show a detailed incoming message.

Scale Your Operations With Custom Automation

Manual processes check growth. We can help you build custom alert pipelines, API integrations, and workflow logic to save your team hours of manual work every week.

Contact us: [yoletech@yolestica.com](mailto:yoletech@yolestica.com) | WhatsApp: +234 802 552 6389

AutomationWorkflowsAPIs