Explore the code and detailed instructions on GitHub
Imagine transforming your WhatsApp into a 24/7 AI assistant that chats in 90+ languages, processes voice notes and images, and hands over to a human agent when needed — all you need is to follow the instructions below, and you can have your business-specific custom AI chatbot replying chats on your current WhatsApp number in under 10 minutes. Don’t believe it? Give it a try!
With Wassenger’s WhatsApp API and this step-by-step guide, you’ll build a ChatGPT-powered, multimodal chatbot that feels like the future is already here.
👉 👉 Explore the code and detailed instructions on GitHub
“In under 10 minutes, you can turn your WhatsApp number into an intelligent, responsive assistant that elevates customer engagement.”
Why Your Business Needs a WhatsApp Chatbot Today
- 📈 Instant Conversations Your customers spend hours on WhatsApp daily — meet them where they already are instead of forcing them to download an app or fill out a form.
- 🤖 Multimodal AI Text, voice transcription, text-to-speech, and even image recognition — all powered by ChatGPT’s latest models.
- 💸 Cost-Effective Scaling Handle hundreds of chats simultaneously without hiring additional staff.
Did you know that over 70% of customers prefer resolving queries via messaging apps over email or phone calls. Here is why WhatsApp and AI automation is key for your business!
Requirements
- PHP 8.1 or higher
- Composer PHP package manager
- WhatsApp Personal or Business number
- Wassenger API key — Sign up for free
- OpenAI API key — Sign up for free
- Ngrok account (for local development) — Sign up for free
👉 Start your 7-day free trial on Wassenger and leverage our powerful WhatsApp automation flows to transform your customer service today! ⚡
5 Steps to Your PHP WhatsApp Bot 🚀
Clone the PHP repository or download the zip file here
git clone https://github.com/wassengerhq/whatsapp-chatgpt-bot-php.git
cd whatsapp-chatgpt-bot-php
Install Dependencies
composer install
Configure Your Environment
cp.env.example.env
# Edit.env with your Wassenger API key, OpenAI API key
# and optionally the Ngrok tunnel user token
# Required: Wassenger API key
# Get it from: https://app.wassenger.com/developers/apikeys
API_KEY=ENTER_API_KEY_HERE
# Required: OpenAI API key
# Get it from: https://platform.openai.com/account/api-keys
OPENAI_API_KEY=
# OpenAI model to use
OPENAI_MODEL=gpt-4o
# Required for local development: Ngrok auth token
# Get it from: https://ngrok.com/signup
NGROK_TOKEN=
# Optional: Webhook URL for production if the program is cloud hosted
WEBHOOK_URL=
# Server port
PORT=8080
Launch the Bot
- Development (with Ngrok local tunnel):
composer run dev
Production:
export WEBHOOK_URL=https://your-domain.com/webhook php public/index.php
Ready to dive in? 👉 Sign up free on Wassenger and grab your API key in minutes.
Core Features You’ll Love
This PHP implementation provides a complete ChatGPT-powered AI chatbot that:
- 🤖 Fully featured chatbot for your WhatsApp number connected to Wassenger
- 💬 Automatic replies to incoming messages from users
- 🌍 Multi-language support — understands and replies in 90+ different languages
- 🎤 Audio input/output—transcription and text-to-speech capabilities
- 🖼️ Image processing — can analyse and understand images
- 👥 Human handoff — allows users to request human assistance
- ⚙️ Customizable AI behaviour and instructions
- 🔧 Function calling capabilities for external data integration
- 📊 Memory management with conversation history and rate limiting
- 🚦 Smart routing with webhook handling and error management
- 🔒 Secure with proper error handling and logging
Pro Tip: Customise the bot’s personality, welcome messages, and rate limits in [src/Config/BotConfig.php](https://github.com/wassengerhq/whatsapp-chatgpt-bot-php/blob/master/src/Config/BotConfig.php).
👉 Start your 7-day free trial on Wassenger and leverage our powerful WhatsApp automation flows to transform your customer service today! ⚡
Customise the chatbot
Simply edit the BotConfig.php file with your business-specific instructions to customise the AI chatbot's behaviour and capabilities:
class BotConfig { // Default welcome message public const WELCOME_MESSAGE = 'Hey there 👋 Welcome to this ChatGPT-powered AI chatbot demo using *Wassenger API*! I can also speak many languages 😁';
// Default help message
public const DEFAULT\_MESSAGE = "Don't be shy 😁 try asking anything to the AI chatbot, using natural language!\\n\\nExample queries:\\n\\n1️⃣ Explain me what is Wassenger\\n2️⃣ Can I use Wassenger to send automatic messages?\\n3️⃣ Can I schedule messages using Wassenger?\\n4️⃣ Is there a free trial available?\\n\\nType \*human\* to talk with a person. The chat will be assigned to an available member of the team.\\n\\nGive it a try! 😁";
// Unknown command message
public const UNKNOWN\_COMMAND\_MESSAGE = "I'm sorry, I was unable to understand your message. Can you please elaborate more?\\n\\nIf you would like to chat with a human, just reply with \*human\*.";
// AI bot instructions
public const BOT\_INSTRUCTIONS = 'You are a smart virtual customer support assistant who works for Wassenger.
You can identify yourself as Milo, the Wassenger AI Assistant. You will be chatting with random customers who may contact you with general queries about the product. Wassenger is a cloud solution that offers WhatsApp API and multi-user live communication services designed for businesses and developers. Wassenger also enables customers to automate WhatsApp communication and build chatbots. You are an expert customer support agent. Be polite. Be helpful. Be emphatic. Be concise. Politely reject any queries that are not related to customer support tasks or Wassenger services itself. Stick strictly to your role as a customer support virtual assistant for Wassenger. Always speak in the language the user prefers or uses. If you can\'t help with something, ask the user to type *human* in order to talk with customer support. Do not use Markdown formatted and rich text, only raw text.';
// Chatbot features
public const FEATURES = \[
'audioInput' => true,
'audioOutput' => true,
'audioOnly' => false,
'voice' => 'echo',
'voiceSpeed' => 1,
'imageInput' => true,
\];
// Template messages
public const TEMPLATE\_MESSAGES = \[
'noAudioAccepted' => 'Audio messages are not supported: gently ask the user to send text messages only.',
'chatAssigned' => 'You will be contact shortly by someone from our team. Thank you for your patience.',
\];
// Rate limits and quotas
public const LIMITS = \[
'maxInputCharacters' => 1000,
'maxOutputTokens' => 1000,
'chatHistoryLimit' => 20,
'maxMessagesPerChat' => 500,
'maxMessagesPerChatCounterTime' => 24 \* 60 \* 60, // 24 hours
'maxAudioDuration' => 2 \* 60, // 2 minutes
'maxImageSize' => 2 \* 1024 \* 1024, // 2MB
\];
}
How It Works Under the Hood
- Modular Architecture
Api/OpenAIClient.phphandles ChatGPT callsApi/WassengerClient.phpconnects to WhatsAppBot/ChatBot.phpprocesses messages and routes logicHttp/WebhookHandler.phplistens for incoming chats
- Customizable Logic
Edit
FunctionHandler.phpto add custom integrations—think order status, FAQs, or appointment booking. This allows you to easily integrate third-party APIs, like CRMs or your custom backend, to retrieve relevant information to let the AI reply to customers’ queries with accurate and updated information, such as order or payment statuses, etc... - Testing & Deployment
php tests/api-test.php
php tests/webhook-test.php
- Deploy on platforms like Render, Heroku, Railway, or Vercel with zero downtime. Find the instructions to deploy the chatbot here.
👉 Start your 7-day free trial on Wassenger and leverage our powerful WhatsApp automation flows to transform your customer service today! ⚡
Ready to run your AI chatbot?
What’s the first customer pain point you’d automate with your new chatbot? 🤔 Have you experimented with AI voices yet, text-to-speech or speech-to-text? Share your thoughts below!
Don’t overthink it — Just act! “The best way to predict the future is to build it.”
- 🎯 Register free at Wassenger and get your bot running in minutes.
- 🚀 See how Wassenger and AI can supercharge your customer support.
Found this helpful? Leave a comment and star the GitHub repo to support the project!






