1. Go to this page and download the library: Download dypras666/wabameta 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/ */
dypras666 / wabameta example snippets
use Dypras666\WabaMeta\Config;
use Dypras666\WabaMeta\Waba;
$config = new Config(
phoneNumberId: 'YOUR_PHONE_NUMBER_ID',
wabaId: 'YOUR_WABA_ID',
accessToken: 'YOUR_ACCESS_TOKEN',
verifyToken: 'YOUR_VERIFY_TOKEN'
);
$waba = new Waba($config);
$waba->sendText('628123456789', 'Hello from WABA Meta!');
// Switch ke mode grup
$waba->setRecipientType('group');
// Kirim pesan teks ke grup
$waba->sendText('GROUP_ID_ANDA', 'Halo semua di grup!');
// Setelah selesai, kembalikan ke individual jika perlu
$waba->setRecipientType('individual');
$response = $waba->createGroup('Nama Group Baru');
$groupId = $response['id'];
use Dypras666\WabaMeta\ComponentBuilder;
$builder = new ComponentBuilder();
$components = $builder
->addDocumentHeader('https://example.com/invoice.pdf', 'Invoice.pdf')
->addBody(['Cabang Jakarta', 'INV-001']) // {{1}} dan {{2}}
->build();
$waba->sendTemplate(
to: '628123456789',
templateName: 'invoice_template',
components: $components
);
use Dypras666\WabaMeta\ComponentBuilder;
$builder = new ComponentBuilder();
$components = $builder
->addTextHeader('Halo Pelanggan!')
->addBody(['Nama User', 'Order #123'])
->addFooter([['type' => 'text', 'text' => 'Terima kasih telah berbelanja!']])
->addUrlButton(0, 'tracking/123') // Menambahkan suffix ke URL button di index 0
->addQuickReplyButton(1, 'YES_CONFIRM') // Payload untuk button di index 1
->build();
$waba->sendTemplate(
to: '628123456789',
templateName: 'order_update',
components: $components
);
$waba->sendCtaUrl(
to: '6281373350813',
body: 'Klik tombol di bawah untuk melihat detail pesanan Anda.',
buttonText: 'Lihat Pesanan',
url: 'https://example.com/order/123',
headerText: 'Info Pesanan',
footerText: 'Berlaku hingga 24 jam'
);
$waba->sendImageCtaUrl(
to: '6281373350813',
imageUrl: 'https://example.com/promo.jpg',
body: 'Promo spesial hari ini! Cek sekarang sebelum kehabisan.',
buttonText: 'Klaim Promo',
url: 'https://example.com/promo',
footerText: 'Syarat & Ketentuan berlaku'
);