Connect GPT-4o to WhatsApp with agentkit: a bot with QR Code, Agent Builder integration, and smart replies for real customers.
How it works, repo, stack
clone, npm install, .env
API key, WORKFLOW_ID
npm run dev, scan, test
agent integration, WORKFLOW_ID
!help, limitations
O WhatsApp AgentKit is a Node.js bot that connects the GPT-4o to WhatsApp via WhatsApp Web. You scan a QR Code, and any message sent to the connected number goes to the GPT agent and returns as an automatic reply.
WhatsApp is the dominant communication channel in Brazil. With this bot, you automate customer service, support, sales, and FAQs with a real AI agent — without paying for expensive official WhatsApp Business APIs.
Repository: github.com/inematds/whatsapp-agentkit
Installing agentkit is simple: clone the repo, install the dependencies with npm, and configure the .env file. In less than 5 minutes, the bot is ready to connect to WhatsApp.
# 1. Clone o repositório git clone https://github.com/inematds/whatsapp-agentkit cd whatsapp-agentkit # 2. Instale as dependências npm install # 3. Copie o arquivo de configuração cp .env.example .env # 4. Edite o .env com suas credenciais nano .env
whatsapp-agentkit/ ├── index.js ← bot principal ├── agent.js ← chamada ao GPT/Agent Builder ├── .env ← suas credenciais ├── .env.example ← template ├── start_dev.bat ← atalho Windows └── package.json
The file .env stores your credentials securely. Never commit it to git. The two main variables are the OpenAI API key and the Agent Builder workflow ID.
# Chave da API da OpenAI OPENAI_API_KEY=sk-proj-... # ID do workflow do Agent Builder (opcional) # Se definido, o bot usa o agente configurado # em vez de GPT-4o direto WORKFLOW_ID=wf_abc123... # Nome do bot (aparece nas mensagens) BOT_NAME=Assistente INEMA
The bot uses the Agent Builder agent with configured guardrails, vector store, and widgets—more customized.
The bot uses GPT-4o directly via API—simpler, with no extra setup.
⚠️ Security: Add .env to .gitignore. Never share the file containing the API key. The .env.example is already in the project's gitignore.
The connection works like WhatsApp Web: you run the bot, it displays a QR Code in the terminal, and you scan it with your phone in Settings → Linked Devices.
# Linux / Mac (terminal) npm run dev # Windows (duplo clique ou terminal) npm start # ou double-click em: start_dev.bat
QR Code appears in the terminal after ~5 seconds
On your phone: WhatsApp → ⋮ → Linked Devices → Link a Device
Scan the QR Code with your phone’s camera
Terminal shows "Client is ready!" — bot is online
Send a message to the connected number and see GPT’s response
The most powerful integration: your agent configured in Agent Builder (with Guardrails, Vector Store, and tools) receives WhatsApp messages and responds like a specialized support agent.
Configure the prompt, guardrails, and tools for customer support
In Agent Builder → Deploy → API → copy the workflow ID (format wf_xxx)
WORKFLOW_ID=wf_seu_id_aqui
WhatsApp messages now go to your custom agent
| Command | Function |
|---|---|
| !help | Lists the available commands |
| !status | Shows whether the bot is active and connected |
| !ping | Test response latency |
| !clear | Clears the conversation history (memory) |
To run 24/7, deploy to a VPS server (AWS, DigitalOcean, Railway):
# Com PM2 (mantém rodando após reinicialização)
npm install -g pm2
pm2 start index.js --name whatsapp-bot
pm2 startup
pm2 save