Back to blog
·4 min read

WhatsApp for Replit — From Replit Agent to Production in 5 Minutes

Add WhatsApp messaging to any Replit project with one prompt to Replit Agent or one npm install. Notify users, send OTPs, run AI chatbots — all from a Repl.

replitwhatsappai agentsnodejsapi

Replit isn't just an in-browser IDE anymore — it's now an agentic platform. Replit Agent can plan, code, and ship a working app from one English prompt; Replit Deployments host it as a public service; and any Repl can run as a long-running backend.

What's been missing: a frictionless way for Replit-built apps (and the Replit Agent itself) to message humans on WhatsApp. Here's how to fix that in 5 minutes flat.

Two ways to add WhatsApp to a Replit project

You'll likely want both depending on what you're building:

  1. Replit Agent generates the integration — describe what you want; the agent writes and deploys the code.
  2. You install the SDK directly — simple npm/pip install, ~5 minutes.

We'll cover both.

Path A: Let Replit Agent build it

In Replit Agent, prompt:

Build a Node.js Express service with a /send endpoint that accepts { to, text } and uses the @gaviwhatsapp/whatsapp SDK to send WhatsApp messages. Read the API key from GAVIWHATSAPP_API_KEY in Secrets. Add a /template endpoint that sends a Meta-approved template by name with variables.

Replit Agent will:

  1. Generate the Express server
  2. Install the SDK
  3. Add GAVIWHATSAPP_API_KEY to Secrets (it'll prompt you to paste your key from gaviventures.com)
  4. Deploy via Replit Deployments

The generated app gives you a working public WhatsApp microservice in under 2 minutes — you can call its public URL from anywhere.

Path B: Manual setup (still ~5 minutes)

Step 1: Create a Node.js Repl

New Repl → Node.js template.

Step 2: Install the SDK

npm install @gaviwhatsapp/whatsapp express

Step 3: Add your API key

Open the Secrets tool (lock icon). Add:

Step 4: Write the service

import express from 'express'
import { WhatsApp } from '@gaviwhatsapp/whatsapp'

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

const wa = new WhatsApp({
  apiKey: process.env.GAVIWHATSAPP_API_KEY
})

app.post('/send', async (req, res) => {
  const { to, text } = req.body
  const result = await wa.send({ to, text })
  res.json(result)
})

app.post('/template', async (req, res) => {
  const { to, template, variables } = req.body
  const result = await wa.sendTemplate({ to, template, language: 'en', variables })
  res.json(result)
})

app.listen(3000, () => console.log('Listening on 3000'))

Step 5: Test it

curl -X POST http://localhost:3000/send \
  -H "Content-Type: application/json" \
  -d '{"to": "+919876543210", "text": "Hello from Replit!"}'

WhatsApp arrives in ~2 seconds.

Production essentials

Use Replit Deployments for production

By default Repls sleep when idle. For a production WhatsApp service, use a Replit Deployment (Autoscale, Reserved VM, or Static depending on your needs) so the service stays reachable on a stable public URL. See Replit's deployment docs for the current options and pricing.

Templates are required for cold messaging

WhatsApp won't let you send free-form text to a user who hasn't messaged you in the last 24 hours. For first-contact (signup notifications, OTPs, order updates), you must use a Meta-approved template. Create one in the Gavi dashboard, submit for approval (~1 hour), then call:

await wa.sendTemplate({
  to: '+919876543210',
  template: 'welcome_message',
  language: 'en',
  variables: { '1': 'Alice' }
})

Webhooks for incoming messages

If you want to receive replies (chatbot, support, two-way flows), expose a webhook endpoint:

app.post('/webhook', express.raw({ type: 'application/json' }), async (req, res) => {
  const body = req.body.toString()
  const signature = req.headers['x-gaviventures-signature']

  if (!wa.verifyWebhookSignature(body, signature, process.env.WEBHOOK_SECRET)) {
    return res.status(401).send('Invalid signature')
  }

  const event = JSON.parse(body)
  console.log(event.event, event.from, event.text)
  res.json({ ok: true })
})

Register the webhook URL (your deployment's public URL + /webhook, e.g. https://your-app.replit.app/webhook) in the Gavi dashboard.

Want an AI agent to handle replies?

This is where Replit + WhatsApp gets really powerful. Instead of writing if/else logic for every user message, route incoming WhatsApp messages to an LLM agent that has the @gaviwhatsapp/mcp server as a tool. The agent reads the message, decides what to do (look up an order, answer a question, escalate to human), and sends a reply via the same MCP tool.

We have a complete walkthrough of that architecture: How to build a WhatsApp chatbot with MCP.

Python version

Same idea, Python flavor:

pip install gaviwhatsapp
from gaviwhatsapp import WhatsApp
import os

wa = WhatsApp(api_key=os.environ["GAVIWHATSAPP_API_KEY"])
wa.send(to="+919876543210", text="Hello from Replit Python!")

Cost

ItemNotes
ReplitFree Starter tier for prototyping; paid plans start at Replit Core ($20/mo billed annually) — see replit.com/pricing
Gavi WhatsApp$9.99/mo flat
Meta per-message chargesBilled directly to your WhatsApp Business Account at Meta's published rates (varies by country and message category)

Cheapest production setup: a paid Replit plan + Gavi's $9.99 — Meta per-message charges are passed through with no markup.


Try it: gaviventures.com · npm

Ready to try Gavi WhatsApp?

Send WhatsApp messages from your code, AI agent, or CRM in under 5 minutes.