PHP code example of automa / laravel-whatsapp

1. Go to this page and download the library: Download automa/laravel-whatsapp 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/ */

    

automa / laravel-whatsapp example snippets


use Automa\WhatsApp\Facades\WhatsApp;

WhatsApp::text('263771234567', 'Hello!');
WhatsApp::buttons('263771234567', 'Choose an option', [
    ['id' => 'products', 'title' => 'Products'],
    ['id' => 'support', 'title' => 'Support'],
]);
WhatsApp::list('263771234567', 'Choose a department', [
    ['title' => 'Departments', 'rows' => [
        ['id' => 'sales', 'title' => 'Sales'],
        ['id' => 'support', 'title' => 'Support'],
    ]],
]);
WhatsApp::template('263771234567', 'welcome', 'en_US');

$conversationManager->put($conversation, 'customer.name', 'Allen');
$name = $conversationManager->state($conversation, 'customer.name');
$conversationManager->putContext($conversation, 'cart.total', 120);

$flow = [
  'nodes' => [
    ['type'=>'reply', 'when'=>['field'=>'text','operator'=>'equals','value'=>'hello'], 'message'=>'Hello {{ state.customer.name }}!'],
    ['type'=>'buttons', 'body'=>'Choose one', 'buttons'=>[
      ['id'=>'products','title'=>'Products'],
      ['id'=>'support','title'=>'Support'],
    ]],
  ],
];
bash
composer whatsapp:install
php artisan migrate