Looking to hire Laravel developers? Try LaraJobs

laravel-ai-smart-reply maintained by amrlotfy

Description
Smart, multilingual AI-powered reply generator for any CRM / ERP / Support system built with Laravel. Supports OpenAI and OpenRouter, with Arabic and English responses.
Author
Last update
2025/10/18 23:11 (dev-main)
License
Links
Downloads
3

Comments
comments powered by Disqus

🧠 Laravel AI Smart Reply

by Amr Lotfy

Smart, multilingual AI-powered reply generator for any CRM / ERP / Support system built with Laravel.
Supports OpenAI and OpenRouter, with Arabic and English responses.


⚙️ Features

  • 🧩 Provider-based architecture (OpenAI, OpenRouter)
  • 🌍 Language support: Arabic / English / Both
  • 💬 Customizable AI prompt templates
  • Plug & play: Works with any CRM, ERP, or Ticket System
  • 🪶 Lightweight & extendable — easy to add new providers

📦 Installation

You can install the package via Composer:

composer require amrlotfy/laravel-ai-smart-reply

If Laravel does not auto-discover the provider, you can manually register it in
config/app.php:

'providers' => [
    AmrLotfy\AiSmartReply\AiSmartReplyServiceProvider::class,
],

Then publish the configuration file:

php artisan vendor:publish --provider="AmrLotfy\AiSmartReply\AiSmartReplyServiceProvider" --tag=config

⚙️ Configuration

Set your environment variables in .env:

AI_SMART_REPLY_PROVIDER=openai
OPENAI_API_KEY=sk-...
OPENAI_MODEL=gpt-4o-mini
OPENROUTER_API_KEY=sk-...
OPENROUTER_MODEL=gpt-4-turbo
AI_SMART_REPLY_LANG=both

🧠 Usage Example

use AmrLotfy\AiSmartReply\Services\AiReply;

// English
$reply = AiReply::generate(
    message: 'Customer: My payment failed',
    context: 'CRM Ticket #552',
    lang: 'en'
);

echo $reply;

// Arabic
$reply = AiReply::generate(
    message: 'العميل قال إن الدفع فشل',
    context: 'تذكرة رقم 552',
    lang: 'ar'
);

echo $reply;

🧩 Configuration File Overview

config/ai-smart-reply.php:

return [
    'default' => 'openai', // or openrouter
    'language' => 'both',  // en | ar | both

    'providers' => [
        'openai' => [...],
        'openrouter' => [...],
    ],

    'templates' => [
        'default' => [
            'en' => "You are a helpful support assistant. Context: {context}. Message: {message}",
            'ar' => "أنت مساعد دعم فني. السياق: {context}. الرسالة: {message}",
        ],
    ],
];

🧱 Extend It

To add another provider, just create a class implementing:

AmrLotfy\AiSmartReply\Providers\AiProviderInterface

and register it in config/ai-smart-reply.php.


🧪 Coming Soon (v1.1)

  • 🧠 Reply caching
  • 🔁 Retry & Rate Limit handling
  • 💬 Streaming responses
  • 🧪 Unit Tests
  • ⚙️ Queue support

🧑‍💻 Author

Amr Lotfy


📄 License

MIT License © 2025 Amr Lotfy