| Install | |
|---|---|
composer require alkoumi/filament-n8n-chat |
|
| Latest Version: | v1.0.1 |
| PHP: | ^8.2 |
A seamless integration of n8n chat widget into your FilamentPHP applications with full multilingual support and theme customization.
composer require alkoumi/filament-n8n-chat
php artisan vendor:publish --tag="filament-n8n-chat-config"
php artisan vendor:publish --tag="filament-n8n-chat-translations"
Add your n8n webhook URL to your .env file: or in config.filament-n8n-chat
N8N_CHAT_ENABLED=true
N8N_CHAT_WEBHOOK_URL=https://your-n8n-instance.com/webhook/your-webhook-id
Register the plugin in your Panel Provider for more control:
// 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
Show chat only for specific user roles:
FilamentN8nChatPlugin::make()
->enabled(fn () => auth()->user()?->hasRole('admin'))
Configure based on current user:
FilamentN8nChatPlugin::make()
->config(function () {
return [
'initialMessages' => auth()->check()
? 'Welcome back, ' . auth()->user()->name . '!'
: 'Hello! How can I help you?',
];
})
You can customize the chat widget appearance by adding custom config options.
Listen to chat events:
window.addEventListener('n8n-chat-ready', (event) => {
console.log('N8n chat is ready!', event.detail.chat);
});
// Programmatically control the chat
window.openN8nChat();
window.closeN8nChat();
window.toggleN8nChat();
window.sendN8nMessage('Hello from code!');
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)The MIT License (MIT). Please see License File for more information.