PHP code example of alkoumi / filament-n8n-chat

1. Go to this page and download the library: Download alkoumi/filament-n8n-chat 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/ */

    

alkoumi / filament-n8n-chat example snippets


// app/Providers/Filament/AdminPanelProvider.php

use Alkoumi\FilamentN8nChat\FilamentN8nChatPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->default()
        ->id('admin')
        ->path('admin')
        // ... other configurations
        ->plugins([
            FilamentN8nChatPlugin::make()
                ->config(function () {
                        $lang = app()->getLocale() ?? 'ar';

                        return [
                            'defaultLanguage' => $lang,
                            'initialMessages' => $lang === 'ar'
                                ? [
                                    'أنا مساعد الذكاء الإصطناعي',
                                    'آمر، كيف أخدمك 💐',
                                ]
                                : [
                                    'Hello! I am your AI assistant',
                                    'How can I help you today?',
                                ],
                            'i18n' => [
                                'en' => [
                                    'title' => 'Hi there! 👋',
                                    'subtitle' => 'I am AI assistant',
                                    'footer' => '',
                                    'getStarted' => 'New Conversation',
                                    'inputPlaceholder' => 'How can I help you today?',
                                ],
                                'ar' => [
                                    'title' => 'مرحبًا بك 💐',
                                    'subtitle' => 'أنا مساعد الذكاء الإصطناعي',
                                    'footer' => '',
                                    'getStarted' => 'محادثة جديدة',
                                    'inputPlaceholder' => 'آمر، كيف أقدر أخدمك 💐',
                                ],
                            ],
                        ];
                    }),
        ]);
}

Just take alook in // config/filament-n8n-chat.php

FilamentN8nChatPlugin::make()
    ->enabled(fn () => auth()->user()?->hasRole('admin'))

FilamentN8nChatPlugin::make()
    ->config(function () {
        return [
            'initialMessages' => auth()->check() 
                ? 'Welcome back, ' . auth()->user()->name . '!'
                : 'Hello! How can I help you?',
        ];
    })
bash
php artisan vendor:publish --tag="filament-n8n-chat-config"
php artisan vendor:publish --tag="filament-n8n-chat-translations"