Wow!Full-featured sandbox for developers — free forever!Register Now
WhatsApp PHP Bot

How to Build a WhatsApp Bot with PHP: Step-by-Step Guide

Updated on August 6, 2026

This step-by-step guide from Whapi.Cloud explains how to build a stable WhatsApp bot in PHP 8.x using native cURL and modern OOP with Composer and Guzzle. Written for PHP developers, this tutorial demonstrates how to bypass Meta's business verification using web-session sockets, set up secure webhooks with Ngrok, implement a self-loop guard to prevent infinite replies, and automate WhatsApp groups up to 1024 members under a flat-rate subscription.

PHP WhatsApp bot integration architecture diagram
About the Author
Jason Mitchell
Jason Mitchell
Product Owner at Whapi.Cloud
Building WhatsApp integrations since 2019. Always happy to connect — whether you want to discuss an API use case, share feedback, or just talk shop. Find me on LinkedIn.
WhatsApp Bot FAQ

Common Questions about PHP WhatsApp Integration

Yes. The single-file native PHP approach has zero external dependencies and runs on standard PHP cURL libraries. This makes it completely compatible with shared cPanel hosting or standard VPS servers. Simply upload your script and point the Whapi.Cloud webhooks to its public URL.
Your bot has full access to native WhatsApp Group features, allowing you to create, manage, and send messages to groups containing up to 1024 members. Unlike Meta's official Cloud API, which severely restricts group sizes for typical business interactions, Whapi provides direct, unrestricted group automation.
Yes. Whapi.Cloud connects via web-session sockets, which mirror the behavior of WhatsApp Web. You can continue using the physical WhatsApp application on your mobile phone to read and write messages manually while your programmatic PHP bot operates in parallel on the same number.
No. Whapi.Cloud uses web-session sockets to pair your regular WhatsApp account (personal or business). This bypasses Facebook Business Manager verification, template approval queues, and per-message Meta fees entirely, allowing you to send organic, conversational text and media immediately.
The Developer Sandbox tier is permanent and completely free. It supports up to 5 active conversations per month, 150 messages per day, and 1,000 API requests per month. This lets you thoroughly test your bot's logic, endpoints, and webhooks before committing to a paid commercial subscription.

See What Our Clients Built
with Whapi.Cloud

"Cart reminders with a 5% follow-up coupon lifted our recovery rate from 4% to 11%. Customers reply directly in WhatsApp — our team closes the sale right there."

Abandoned Cart Recovery

Hans M., Germany
"Managing 40+ segment groups became trivial — auto welcome messages, pinned updates, inactive member cleanup. Lead gen from WhatsApp groups grew 3x in two months."

Automated Group Management at Scale

Carlos S., Brazil
"Guests receive door codes, WiFi credentials, and a local guide automatically on arrival. Checkout is confirmed via a photo on WhatsApp. Front desk load dropped 40% in the first month."

Contactless Hotel Operations

Ana M., Romania
"Our deals channel has 12,000 subscribers. Whapi.Cloud scrapes competitors, filters duplicates, and auto-posts the top 5 daily. Channel growth tripled after switching to automated posting."

Automated Deal Channel Publishing

Katrin S., Germany
"We verified 93,000 active WhatsApp numbers from 180,000 contacts in 48 hours. Campaign open rates improved significantly by stopping spend on inactive numbers."

Large-Scale Audience Filtering

Sergio N., Spain
"Patients book appointments and check lab results on WhatsApp. The bot handles 200+ daily queries without staff. Appointment no-shows dropped 30% after automated 24h reminders."

Healthcare Bot — Scheduling & Results

Dr. Fernanda O., Brazil
"Post-purchase WhatsApp messages with a tailored discount at day 14. Birthday coupons see 45% redemption — far above our email rate. Repeat purchases via WhatsApp: 18% of total revenue."

WhatsApp Retention Campaigns

Lukas W., Germany
"Customers get a WhatsApp tracking link the moment their parcel ships. Support tickets dropped 35% in 3 months — mostly 'where is my order?' queries simply disappeared."

Automated Shipping Notifications

Matei P., Romania
Inhouse Developed & Managed

What is Whapi.Cloud?

Whapi.Cloud is an intuitive API that connects your business with WhatsApp -- directly and without complexity. Build support bots, schedule appointments, send notifications, manage groups and channels, automate order confirmations, and track everything with webhooks. Focus on growing your business while the API handles the messaging layer.

Our service provides full control and management of WhatsApp groups, communities and channels.

Add dynamics and new features: media, buttons, reactions, stories, orders and products. All of these are available to you for customer interaction.

Our care team will respond quickly and help you with any questions you may have!
Account screenshot
Account screenshot