### Install Filament WhatsApp Connector via Composer Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Use Composer to add the package to your Laravel project. This is the first step in the installation process. ```bash composer require wallacemartinss/filament-whatsapp-conector ``` -------------------------------- ### Example: Full Filament Evolution Plugin Configuration Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Demonstrates how to enable all available resources for the Filament Evolution plugin, including WhatsApp instances, message history, and webhook logs. ```php FilamentEvolutionPlugin::make() ->whatsappInstanceResource() // Show instances (default: true) ->viewMessageHistory() // Show message history ->viewWebhookLogs() // Show webhook logs ``` -------------------------------- ### Start Laravel Queue Worker Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Run this command to start the queue worker, which is essential for processing webhooks and sending messages. For production environments, consider using a process manager like Supervisor. ```bash php artisan queue:work ``` -------------------------------- ### Custom Storage Disk for File Uploads Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Configure a custom storage disk for file uploads within the 'Send Whatsapp Message' action, for example, to use S3. ```php SendWhatsappMessageAction::make() ->disk('s3') // Use S3 for file uploads ``` -------------------------------- ### Use Trait for Sending WhatsApp Messages Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Integrates WhatsApp message sending capabilities into a class using a trait. This example shows sending PIX options within a service class. ```php use WallaceMartinss\FilamentEvolution\Concerns\CanSendWhatsappMessage; class CheckoutService { use CanSendWhatsappMessage; public function sendPaymentOptions(Order $order): void { $this->sendWhatsappPix( number: $order->customer->phone, description: "Order #{$order->number} — R$ {$order->total}", pix: [ 'currency' => 'BRL', 'name' => config('app.name'), 'keyType' => 'random', 'key' => $order->pix_key, ], title: 'Complete your purchase', ); } } ``` -------------------------------- ### Publish Filament Evolution Migrations and Run Migrations Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Publish and run the database migrations for the Filament Evolution package. This sets up the necessary database tables. ```bash php artisan vendor:publish --tag="filament-evolution-migrations" php artisan migrate ``` -------------------------------- ### Run Tests with Composer Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Execute the project's test suite using the Composer command. This is a standard way to verify the integrity and functionality of the codebase. ```bash composer test ``` -------------------------------- ### Filament Evolution Configuration Options Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Key settings for queue, storage, cleanup policies, instance defaults, and multi-tenancy are defined in this configuration file. Adjust these to match your application's needs. ```php // config/filament-evolution.php return [ // Queue settings 'queue' => [ 'enabled' => true, 'connection' => null, // null = default connection 'name' => 'default', // queue name ], // Storage settings 'storage' => [ 'webhooks' => true, // save webhooks to database 'messages' => true, // save messages to database ], // Cleanup policy (automatic deletion of old records) 'cleanup' => [ 'webhooks_days' => 30, // delete webhooks older than 30 days 'messages_days' => 90, // delete messages older than 90 days ], // Instance defaults 'instance' => [ 'reject_call' => false, 'always_online' => false, // ... ], // Multi-tenancy 'tenancy' => [ 'enabled' => false, 'column' => 'team_id', 'table' => 'teams', 'model' => 'App\\Models\\Team', ], ]; ``` -------------------------------- ### Configure Media Storage Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Set environment variables to configure the disk, directory, and maximum size for media files. ```env EVOLUTION_MEDIA_DISK=public EVOLUTION_MEDIA_DIRECTORY=whatsapp-media EVOLUTION_MEDIA_MAX_SIZE=16384 ``` -------------------------------- ### Send Document with Custom Disk Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Use the Facade or Action to send documents, specifying a custom storage disk like 's3'. ```php // Using the Facade with S3 Whatsapp::sendDocument($instanceId, $number, 'documents/report.pdf', 'report.pdf', null, 's3'); // Using the Action with custom disk SendWhatsappMessageAction::make()->disk('s3'); ``` -------------------------------- ### Schedule Daily Cleanup Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Schedule the evolution:cleanup command to run daily by adding it to your console routes. ```php use Illuminate\Support\Facades\Schedule; Schedule::command('evolution:cleanup')->daily(); ``` -------------------------------- ### Configure Multi-Tenancy Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Edit the configuration file to enable and configure multi-tenancy, specifying tenant column, table, model, and column type. ```php 'tenancy' => [ 'enabled' => true, 'column' => 'team_id', 'table' => 'teams', 'model' => 'App\\Models\\Team', 'column_type' => 'uuid', // 'uuid' or 'id' ] ``` -------------------------------- ### Customize Filament Evolution Plugin Options Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Configure which resources are displayed in the Filament panel by calling specific methods on the plugin instance. Defaults are shown. ```php FilamentEvolutionPlugin::make() ->viewMessageHistory() // Enable message history resource ->viewWebhookLogs() // Enable webhook logs resource ``` -------------------------------- ### Generic send() Helper for WhatsApp Messages Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Demonstrates the generic `send()` method for various message types including buttons, lists, and carousels. The third argument specifies the message type. ```php Whatsapp::send($instanceId, '5511999999999', 'buttons', [ 'description' => 'Choose:', 'title' => 'Menu', 'footer' => null, 'buttons' => [ ['type' => 'reply', 'displayText' => 'A', 'id' => 'a'], ['type' => 'reply', 'displayText' => 'B', 'id' => 'b'], ], ]); Whatsapp::send($instanceId, '5511999999999', 'list', [ 'title' => 'Menu', 'description' => 'Pick one', 'buttonText' => 'Open', 'sections' => [/* ... */], ]); Whatsapp::send($instanceId, '5511999999999', 'carousel', [ 'message' => 'Our products', 'cards' => [/* ... */], ]); ``` -------------------------------- ### Send Audio Message via Whatsapp Facade Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Send an audio message using the Whatsapp facade. Requires instance ID, recipient number, and audio file path. ```php use WallaceMartinss\FilamentEvolution\Facades\Whatsapp; // Send audio Whatsapp::sendAudio($instanceId, '5511999999999', 'path/to/audio.mp3'); ``` -------------------------------- ### Send Video Message via Whatsapp Facade Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Send a video message with an optional caption using the Whatsapp facade. Requires instance ID, recipient number, video path, and caption. ```php use WallaceMartinss\FilamentEvolution\Facades\Whatsapp; // Send video with caption Whatsapp::sendVideo($instanceId, '5511999999999', 'path/to/video.mp4', 'Watch this!'); ``` -------------------------------- ### Publish Filament Evolution Configuration Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Publish the configuration files for the Filament Evolution package using Artisan. This makes the configuration accessible for customization. ```bash php artisan vendor:publish --tag="filament-evolution-config" ``` -------------------------------- ### Use Evolution Client Directly in PHP Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Utilize the EvolutionClient service for advanced operations like creating instances, checking connection states, and sending various message types. Ensure the EvolutionClient service is available in your application container. ```php use WallaceMartinss\FilamentEvolution\Services\EvolutionClient; $client = app(EvolutionClient::class); // Create instance $response = $client->createInstance('my-instance', '5511999999999', true, [ 'reject_call' => true, 'always_online' => true, ]); // Get connection state $state = $client->getConnectionState('my-instance'); // Send text message $client->sendText('my-instance', '5511999999999', 'Hello World!'); // Send image (path is base64 encoded by the service) $client->sendImage('my-instance', '5511999999999', $base64Content, 'image.jpg', 'Check this!'); ``` -------------------------------- ### Send Document Message via Whatsapp Facade Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Send a document message with an optional filename and caption using the Whatsapp facade. Requires instance ID, recipient number, file path, filename, and caption. ```php use WallaceMartinss\FilamentEvolution\Facades\Whatsapp; // Send document Whatsapp::sendDocument($instanceId, '5511999999999', 'path/to/file.pdf', 'report.pdf', 'Monthly Report'); ``` -------------------------------- ### Environment Variables for Evolution API and Webhooks Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Configure your API connection details and webhook settings using these environment variables. Ensure all required fields are populated for proper functionality. ```env # Evolution API Connection (Required) EVOLUTION_URL=https://your-evolution-api.com EVOLUTION_API_KEY=your_api_key # Webhook Configuration (Required for receiving events) EVOLUTION_WEBHOOK_URL=https://your-app.com/api/webhooks/evolution EVOLUTION_WEBHOOK_SECRET=your_secret_key EVOLUTION_WEBHOOK_PATH=api/webhooks/evolution # Storage Options (Optional - defaults to true) EVOLUTION_STORE_WEBHOOKS=true EVOLUTION_STORE_MESSAGES=true # Instance Settings (Optional) EVOLUTION_QRCODE_EXPIRES=30 EVOLUTION_DEFAULT_INSTANCE=your_instance_id ``` -------------------------------- ### Pre-fill Send Whatsapp Message Action Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Configure default values for the 'Send Whatsapp Message' action, such as the phone number, instance, and message content. ```php SendWhatsappMessageAction::make() ->number('5511999999999') // Default phone number ->instance($instanceId) // Default instance ->message('Hello World!') // Default message ``` -------------------------------- ### Webhook URL Configuration Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md The default webhook route is '/api/webhooks/evolution'. Ensure your EVOLUTION_WEBHOOK_URL environment variable matches this path. ```text https://your-app.com/api/webhooks/evolution ``` -------------------------------- ### Send Contact Card via Whatsapp Facade Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Send a contact card using the Whatsapp facade. Requires instance ID, recipient number, contact name, and contact phone number. ```php use WallaceMartinss\FilamentEvolution\Facades\Whatsapp; // Send contact card Whatsapp::sendContact($instanceId, '5511999999999', 'John Doe', '+5511888888888'); ``` -------------------------------- ### Configure Tailwind CSS for Filament Evolution Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Add the plugin's views and source files to your Filament theme's CSS file to ensure proper styling and integration. Rebuild assets afterward. ```css @import '../../../../vendor/filament/filament/resources/css/theme.css'; @source '../../../../app/Filament/**/*'; @source '../../../../resources/views/filament/**/*'; /* Add these lines for Filament Evolution */ @source '../../../../vendor/wallacemartinss/filament-whatsapp-conector/resources/views/**/*'; @source '../../../../vendor/wallacemartinss/filament-whatsapp-conector/src/**/*'; ``` -------------------------------- ### Generic Send Method via Whatsapp Facade Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Use the generic 'send' method of the Whatsapp facade for various message types. Supports text and image with optional parameters. ```php use WallaceMartinss\FilamentEvolution\Facades\Whatsapp; // Generic send method Whatsapp::send($instanceId, '5511999999999', 'text', 'Hello World!'); Whatsapp::send($instanceId, '5511999999999', 'image', 'path/to/image.jpg', ['caption' => 'Nice!']); ``` -------------------------------- ### Send Image Message via Whatsapp Facade Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Send an image message with an optional caption using the Whatsapp facade. Requires instance ID, recipient number, image path, and caption. ```php use WallaceMartinss\FilamentEvolution\Facades\Whatsapp; // Send image with caption Whatsapp::sendImage($instanceId, '5511999999999', 'path/to/image.jpg', 'Check this out!'); ``` -------------------------------- ### Sending Reply Buttons with Whatsapp Facade Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Utilize the `Whatsapp::sendButtons` method to send interactive messages with reply buttons. Ensure the `instanceId` is provided and the buttons are correctly formatted. ```php use WallaceMartinss\FilamentEvolution\Facades\Whatsapp; Whatsapp::sendButtons( instanceId: $instanceId, number: '5511999999999', description: 'Would you like to confirm your appointment?', buttons: [ ['type' => 'reply', 'displayText' => 'Yes', 'id' => 'confirm-yes'], ['type' => 'reply', 'displayText' => 'No', 'id' => 'confirm-no'], ['type' => 'reply', 'displayText' => 'Reschedule', 'id' => 'reschedule'], ], title: 'Appointment Confirmation', footer: 'Reply within 24h', ); ``` -------------------------------- ### Run Cleanup Command Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Execute the cleanup command to remove old records. Use --dry-run to preview deletions. ```bash php artisan evolution:cleanup ``` ```bash php artisan evolution:cleanup --dry-run ``` ```bash php artisan evolution:cleanup --webhooks-days=7 --messages-days=30 ``` -------------------------------- ### Send Location Message via Whatsapp Facade Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Send a location message using the Whatsapp facade. Requires instance ID, recipient number, latitude, longitude, name, and address. ```php use WallaceMartinss\FilamentEvolution\Facades\Whatsapp; // Send location Whatsapp::sendLocation($instanceId, '5511999999999', -23.5505, -46.6333, 'My Office', 'São Paulo, SP'); ``` -------------------------------- ### Customizing WhatsApp Instance Selection Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Override the `getWhatsappInstanceId` method within a service to specify a particular WhatsApp instance for sending messages, useful for multi-tenant applications. ```php class TenantInvoiceService { use CanSendWhatsappMessage; protected function getWhatsappInstanceId(): ?string { // Use tenant's specific WhatsApp instance return auth()->user()->tenant->whatsapp_instance_id; } } ``` -------------------------------- ### Register Filament Evolution Plugin in Panel Provider Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Add the FilamentEvolutionPlugin to your Filament panel configuration. This integrates the plugin's features into your admin panel. ```php use WallaceMartinss\FilamentEvolution\FilamentEvolutionPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ FilamentEvolutionPlugin::make(), ]); } ``` -------------------------------- ### Send Text Message via Whatsapp Facade Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Send a simple text message using the Whatsapp facade. Requires instance ID, recipient number, and message content. ```php use WallaceMartinss\FilamentEvolution\Facades\Whatsapp; // Send text Whatsapp::sendText($instanceId, '5511999999999', 'Hello!'); ``` -------------------------------- ### Sending Various WhatsApp Messages with Trait Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Integrate the `CanSendWhatsappMessage` trait into your services to send text, documents, and images via WhatsApp. Ensure the `Invoice` and `Customer` models have the necessary attributes. ```php use WallaceMartinss\FilamentEvolution\Concerns\CanSendWhatsappMessage; class InvoiceService { use CanSendWhatsappMessage; public function sendPaymentReminder(Invoice $invoice): void { $this->sendWhatsappText( $invoice->customer->phone, "Hello {$invoice->customer->name}, your invoice #{$invoice->number} is due on {$invoice->due_date->format('d/m/Y')}." ); } public function sendInvoicePdf(Invoice $invoice): void { $this->sendWhatsappDocument( $invoice->customer->phone, $invoice->pdf_path, "invoice-{$invoice->number}.pdf", "Your invoice is ready!" ); } public function sendPromoImage(Customer $customer, string $imagePath): void { $this->sendWhatsappImage( $customer->phone, $imagePath, "Special promotion just for you! 🎉" ); } } ``` -------------------------------- ### Send Whatsapp Message Action in Filament Table Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Add a 'Send Whatsapp Message' action to a Filament table. This allows users to send messages directly from table rows. ```php use WallaceMartinss\FilamentEvolution\Actions\SendWhatsappMessageAction; // In a table public function table(Table $table): Table { return $table ->actions([ SendWhatsappMessageAction::make(), ]); } ``` -------------------------------- ### Filament Action for Sending WhatsApp Messages Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Configures the `SendWhatsappMessageAction` for use in Filament. It automatically handles form fields based on allowed message types. ```php SendWhatsappMessageAction::make() ->allowedTypes([ MessageTypeEnum::BUTTONS, MessageTypeEnum::CTA, MessageTypeEnum::PIX, MessageTypeEnum::LIST, MessageTypeEnum::CAROUSEL, ]); ``` -------------------------------- ### Send Whatsapp Message Action in Filament Page Header Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Include a 'Send Whatsapp Message' action in the header of a Filament page. This provides a convenient way to initiate messages from a page context. ```php use WallaceMartinss\FilamentEvolution\Actions\SendWhatsappMessageAction; // In a page header protected function getHeaderActions(): array { return [ SendWhatsappMessageAction::make(), ]; } ``` -------------------------------- ### Sending CTA Buttons (URL/Call/Copy) with Whatsapp Facade Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Send interactive messages with Call To Action buttons using `Whatsapp::sendCta`. This method supports URL links, phone number calls, and code copying. ```php Whatsapp::sendCta( instanceId: $instanceId, number: '5511999999999', description: 'Tap below to visit our site or call us.', buttons: [ ['type' => 'url', 'displayText' => 'Visit Site', 'url' => 'https://example.com'], ['type' => 'call', 'displayText' => 'Call Us', 'phoneNumber' => '+5511888888888'], // Also supported: ['type' => 'copy', 'displayText' => 'Copy Code', 'copyCode' => 'PROMO10'] ], ); ``` -------------------------------- ### Send List Message Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Use this to send a structured list message with sections and rows. The button text and sections are customizable. ```php Whatsapp::sendList( instanceId: $instanceId, number: '5511999999999', title: 'Main Menu', description: 'Pick an option to continue', buttonText: 'View options', sections: [ [ 'title' => 'Support', 'rows' => [ ['title' => 'Track order', 'description' => 'Check delivery status', 'rowId' => 'track'], ['title' => 'Open ticket', 'description' => 'Talk to a human', 'rowId' => 'ticket'], ], ], [ 'title' => 'Sales', 'rows' => [ ['title' => 'Catalog', 'rowId' => 'catalog'], ['title' => 'Promotions', 'rowId' => 'promo'], ], ], ], footerText: 'We reply 24/7', ); ``` -------------------------------- ### Send PIX Message Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Use this to send a PIX payment request. Ensure all required PIX details are provided. ```php Whatsapp::sendPix( instanceId: $instanceId, number: '5511999999999', description: 'Pay your invoice with PIX', pix: [ 'currency' => 'BRL', 'name' => 'ACME LTDA', 'keyType' => 'phone', // phone | email | cpf | cnpj | random 'key' => '5511888888888', 'amount' => 199.90, // optional — omit to let the recipient type the value ], title: 'Invoice #12345', footer: 'Due today', ); ``` -------------------------------- ### Dynamically Set Number for Send Whatsapp Message Action Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Configure the 'Send Whatsapp Message' action to automatically determine the recipient's phone number from a record attribute, relationship, or custom logic. ```php // Using attribute name SendWhatsappMessageAction::make() ->numberFrom('phone'), // Using dot notation for relationships SendWhatsappMessageAction::make() ->numberFrom('contact.phone'), // Using closure for custom logic SendWhatsappMessageAction::make() ->numberFrom(fn ($record) => $record->celular ?? $record->telefone), // Also set instance from record SendWhatsappMessageAction::make() ->numberFrom('phone') ->instanceFrom('whatsapp_instance_id'), ``` -------------------------------- ### Hide Fields in Send Whatsapp Message Action Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Customize the 'Send Whatsapp Message' action by hiding specific form fields like the instance selector or phone number input, or restrict to text-only messages. ```php SendWhatsappMessageAction::make() ->hideInstanceSelect() // Hide instance selector ->hideNumberInput() // Hide phone number input ->textOnly() // Only allow text messages (hide file upload) ``` -------------------------------- ### Send Carousel Message Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Use this to send a carousel of cards, each with an image, header, body, and buttons. Buttons can be reply or URL types. ```php Whatsapp::sendCarousel( instanceId: $instanceId, number: '5511999999999', message: 'Check out our top picks 🛍️', cards: [ [ 'imageUrl' => 'https://cdn.example.com/product-a.jpg', 'header' => 'Product A', 'body' => 'Limited edition • R$ 199', 'buttons' => [ ['type' => 'reply', 'displayText' => 'Buy now', 'id' => 'buy-a'], ['type' => 'url', 'displayText' => 'Details', 'url' => 'https://example.com/a'], ], ], [ 'imageUrl' => 'https://cdn.example.com/product-b.jpg', 'header' => 'Product B', 'body' => 'Best seller • R$ 299', 'buttons' => [ ['type' => 'reply', 'displayText' => 'Buy now', 'id' => 'buy-b'], ], ], ], ); ``` -------------------------------- ### Limit Message Types in Send Whatsapp Message Action Source: https://github.com/wallacemartinss/filament-whatsapp-conector/blob/v2/README.md Restrict the types of messages that can be sent using the 'Send Whatsapp Message' action. Supports TEXT and IMAGE types. ```php use WallaceMartinss\FilamentEvolution\Enums\MessageTypeEnum; SendWhatsappMessageAction::make() ->allowedTypes([ MessageTypeEnum::TEXT, MessageTypeEnum::IMAGE, ]); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.