1. Go to this page and download the library: Download emam/whatsapp-manager library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
emam / whatsapp-manager example snippets
use Emam\WhatsappManager\Config\ConfigManager;
use Emam\WhatsappManager\WhatsappManager;
use Emam\WhatsappManager\Messages\WhatsappMessage;
// 1. Load Configuration
$config = new ConfigManager(pp Manager!')
);
// 4. Send Media Message (Image)
$message = WhatsappMessage::create()
->image('https://example.com/image.png', 'Check this out!');
$manager->driver()->send('+1234567890', $message);
// 5. Send Location
$message = WhatsappMessage::create()
->location(25.2048, 55.2708, 'Burj Khalifa', '1 Sheikh Mohammed bin Rashid Blvd');
$manager->driver()->send('+1234567890', $message);
// 6. Upload Media & Send
$driver = $manager->driver('official');
$upload = $driver->uploadMedia('/path/to/image.jpg', 'image');
$mediaId = $upload['id'];
$message = WhatsappMessage::create()
->image($mediaId, 'Uploaded image');
$driver->send('+1234567890', $message);
// 7. Reply to Message
$message = WhatsappMessage::create('This is a reply')
->reply('wamid.HBg...');
$manager->driver()->send('+1234567890', $message);
// 8. Send Template Message (Official Driver)
$message = WhatsappMessage::create()
->template('hello_world', 'en_US');
$manager->driver('official')->send('+1234567890', $message);
// 9. Send Interactive Button Message
$manager->sendButtonMessage('123456')
->to('+1234567890')
->withBody('Do you confirm your appointment for tomorrow at 3 PM?')
->addButton('confirm', '✅ Confirm')
->addButton('reschedule', '🔄 Reschedule')
->addButton('cancel', '❌ Cancel')
->withFooter('Please select an option')
->send();
// 10. Send Interactive List Message
$manager->sendListMessage('123456')
->to('+1234567890')
->withButtonText('View Products')
->withBody('Our featured products:')
->withHeader('Digital Catalog')
->startSection('Laptops')
->addRow('laptop-pro', 'MacBook Pro', '16" - 32GB RAM - 1TB SSD')
->addRow('laptop-air', 'MacBook Air', '13" - M2 Chip - 8GB RAM')
->endSection()
->startSection('Smartphones')
->addRow('iphone-15', 'iPhone 15 Pro', '48MP Camera - 5G')
->addRow('samsung-s23', 'Samsung S23', '120Hz AMOLED Display')
->endSection()
->send();
// Get all templates
$templates = $manager->driver('official')->getTemplates(100);
// Create a template
$template = $manager->driver('official')->createTemplate(
'order_confirmation',
'UTILITY',
'en_US',
[
['type' => 'BODY', 'text' => 'Your order {{1}} has been confirmed.']
]
);
// Delete a template
$manager->driver('official')->deleteTemplate('order_confirmation');
use Emam\WhatsappManager\Templates\TemplateBuilder;
$driver = $manager->driver('official');
// Create a complete template with fluent API
$template = TemplateBuilder::create($driver)
->utility()
->name('order_confirmation')
->language('en_US')
->header('Order Confirmed', 'text')
->body('Your order {{1}} has been confirmed. Delivery: {{2}}')
->footer('Thank you for your order!')
->quickReplyButton('Track Order')
->quickReplyButton('Contact Support')
->build();
// Marketing template with image
$template = TemplateBuilder::create($driver)
->marketing()
->name('summer_sale')
->language('en_US')
->header('', 'image') // Image header
->body('Summer Sale! Get {{1}}% off. Use code: {{2}}')
->footer('Valid until end of month')
->urlButton('Shop Now', 'https://example.com/sale')
->build();