PHP code example of jeffersongoncalves / laravel-whatsapp-widget

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

    

jeffersongoncalves / laravel-whatsapp-widget example snippets


@

@

use JeffersonGoncalves\WhatsappWidget\Models\WhatsappAgent;

WhatsappAgent::create([
    'active' => true,
    'name' => 'Customer Support',
    'phone' => '+1234567890',
    'text' => 'Hello! I have a question about your product.',
    'image' => 'path/to/agent-avatar.jpg', // Optional
]);

return [
    // Enable or disable audio notification
    'audio' => true,

    // Play audio notification once per day or on every page load
    'play_audio_daily' => true,

    // Filesystem disk for storing agent images
    'disk' => env('FILESYSTEM_DISK', 'local'),

    // Application URL (used for redirection)
    'url' => env('APP_URL', 'http://localhost'),

    // Application name (displayed in the widget)
    'name' => env('APP_NAME', 'Laravel App'),

    // WhatsApp API key (if needed)
    'key' => env('WHATSAPP_KEY'),

    // Widget position on the screen (left or right)
    'position' => 'right',

    // Colors for the floating button and the modal that opens
    'colors' => [
        'primary' => '#03cc0b',      // Button, modal header and base accents
        'primary_text' => '#ffffff', // Text/icon on top of the primary color
        'badge' => '#ff0000',        // Notification badge background
        'modal_bg' => '#ffffff',     // Modal (popup) background
        'modal_text' => '#000000',   // Agent name / main text inside the modal
        'modal_muted' => '#bababa',  // Secondary / muted text inside the modal
        'online' => '#03cc0b',       // Online status dot and label
    ],

    // Colors for the redirect (loading) screen
    'redirect' => [
        'background' => '#f1f1f1',
        'text' => '#7e7e7e',
        'name' => '#333333',
        'accent' => '#03cc0b',
        'spinner' => '#92d1c3',
    ],

    // Custom icons (null = bundled defaults). Provide a public URL or path.
    'icons' => [
        'trigger' => null,  // Floating button + modal header icon
        'avatar' => null,   // Fallback agent avatar (when an agent has no image)
        'redirect' => null, // Small icon shown on the redirect screen
    ],
];

'position' => 'left',

'position' => 'right',

'colors' => [
    'primary' => '#25D366',      // Button, modal header and accents
    'primary_text' => '#ffffff', // Text/icon on top of the primary color
    'badge' => '#ff0000',        // Notification badge background
    'modal_bg' => '#ffffff',     // Modal background
    'modal_text' => '#111111',   // Agent name / main text
    'modal_muted' => '#9aa0a6',  // Secondary text
    'online' => '#25D366',       // Online status dot and label
],

'redirect' => [
    'background' => '#f1f1f1',
    'text' => '#7e7e7e',
    'name' => '#333333',
    'accent' => '#25D366',
    'spinner' => '#92d1c3',
],

'icons' => [
    'trigger' => asset('images/my-whatsapp.svg'), // Floating button + modal header
    'avatar' => asset('images/my-avatar.png'),    // Fallback agent avatar
    'redirect' => asset('images/my-icon.png'),    // Redirect screen icon
],
bash
php artisan vendor:publish --tag=whatsapp-widget-config
bash
php artisan vendor:publish --tag=whatsapp-widget-migrations
bash
php artisan vendor:publish --tag=whatsapp-widget-assets
bash
php artisan vendor:publish --tag=whatsapp-widget-translations
bash
php artisan vendor:publish --tag=whatsapp-widget-views
bash
php artisan migrate