codebuglab / letsbot-php
Official PHP client for the LetsBot WhatsApp Business API. Seamlessly integrate WhatsApp messaging into your PHP & Laravel applications to automate customer communication, build chatbots, send notifications, and manage interactions.
Fund package maintenance!
Other
Requires
- php: ^7.4|^8.0
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- mockery/mockery: ^1.5
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^9.0|^10.0
- vlucas/phpdotenv: ^5.3
README
A comprehensive PHP package for integrating with the LetsBot WhatsApp API. This package provides a powerful, easy-to-use interface to leverage WhatsApp's extensive messaging capabilities in your PHP applications.
LetsBot transforms business messaging by providing access to WhatsApp's platform, used by 2 billion people worldwide with 60 billion daily messages. Our RESTful API enables you to connect your WhatsApp number to various third-party systems, programming languages, CMS, CRMs & CLI tools with minimal hassle and no complex dependencies.
Table of Contents
- Requirements
- Installation
- Configuration
- Basic Usage
- API Features
- Documentation
- Testing
- Compatibility
- License
- Support
Requirements
- PHP 7.4 or higher
- Guzzle HTTP 7.0 or higher
- A LetsBot account with API credentials
Installation
Laravel
If you're using Laravel, install the package via Composer:
composer require codebuglab/letsbot-php
After installation, publish the configuration file:
php artisan vendor:publish --tag=letsbot-config
You can find the config file in config/letsbot.php
.
PHP Native
For PHP native or OOP applications:
require 'vendor/autoload.php'; $lb = (new \LetsBot\Api\LetsBot); $lb::$api_key = 'your_api_key'; // Set API key $lb::$ssl_verify = false; // Set SSL verification (true/false, default is true) $result = $lb->ChatList()->send(); echo json_encode($result);
Configuration
The configuration file contains essential settings for the API connection:
return [ 'api_key' => env('LETS_BOT_API_KEY', 'test'), 'ssl_verify' => true, ];
api_key
: Your API key generated from the LetsBot dashboardssl_verify
: This option can disable SSL certificate verification if you're in development. Set tofalse
to skip SSL certificate errors.
Basic Usage
The package provides an alias LetsBot\Api\LetsBot::class
for easy use:
// In Laravel use LetsBot; return LetsBot::sessionStatus()->send(); // OR use the helper function return lb()->sessionStatus()->send();
All methods follow a common pattern:
-
Fluent interface:
LetsBot::method()->param1(value)->param2(value)->send();
-
Array parameter:
LetsBot::method()->send([ 'param1' => value, 'param2' => value ]);
Example: Sending a Text Message
// Fluent interface LetsBot::message() ->phone('1234567890') ->body('Hello from LetsBot!') ->send();
API Features
The LetsBot PHP package provides comprehensive access to all WhatsApp Business API features:
- Message Operations - Send texts, react to messages, reply to specific messages, mentions, and more
- Media Messages - Share images, videos, documents, audio clips, and other media content
- Interactive Messages - Create button messages, list messages, and other interactive content
- Chat Operations - Manage chats, set status, archive conversations, and more
- Group Operations - Create and manage groups, add/remove participants, and group settings
- User Operations - Check presence, manage profiles, block/unblock users
- Product Operations - Manage product catalogs and listings
- Instance Operations - Manage your WhatsApp instance settings and status
- Authentication - Handle QR codes and session management
Documentation
For detailed documentation on all available features and methods, please refer to the following guides:
- Message Operations - Text messages, stickers, reactions, replies, and message management
- Media Messages - Images, videos, files, audio, and other media types
- Button Messages - Interactive button messages with various configurations
- List Messages - Structured lists with sections and items
- Chat Operations - Managing conversations and chat settings
- Group Operations - Creating and managing groups
- User Operations - User management and profiles
- Product Operations - Product catalogs and management
- Instance Operations - Instance configuration and status
- QR Code and Sessions - Authentication and session management
Testing
The package includes comprehensive test coverage. To run tests:
composer test
To generate code coverage reports:
composer test-coverage
This will generate an HTML code coverage report in the coverage
directory.
Compatibility
This package is tested with PHP 7.4, 8.0, 8.1, and 8.2 to ensure maximum compatibility across different environments and projects.
License
The MIT License (MIT). Please see License File for more information.
Support
Need assistance? Contact the LetsBot support team:
- Email: sales@letsbot.net
- Phone/WhatsApp: +966559408401
- Documentation: https://docs.letsbot.net