PHP code example of omdiaries / laravel-ai-email-assistant

1. Go to this page and download the library: Download omdiaries/laravel-ai-email-assistant 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/ */

    

omdiaries / laravel-ai-email-assistant example snippets


use OmDiaries\AiEmailAssistant\Facades\AiEmail;

$email = AiEmail::generate([
    'template' => 'invoice',
    'tone' => 'friendly',
    'outputType' => 'html',
]);

Mail::to('[email protected]')->send(new InvoiceMail($email));

return [

    // Default AI provider
    'default_provider' => env('AI_PROVIDER', 'openai'),

    // Available providers
    'providers' => [
        'openai' => [
            'api_key' => env('AI_API_KEY'),
        ],
        'gemini' => [
            'api_key' => env('AI_API_KEY'),
        ],
    ],

    // Default tone for generated emails
    'default_tone' => env('AI_TONE', 'formal'),

    // Output type: text, html, markdown
    'default_output' => env('AI_OUTPUT_TYPE', 'html'),

    // Enable or disable logging of AI responses
    'logging' => true,

    // Prompt templates
    'templates' => [
        'welcome' => 'Write a warm welcome email for a new user...',
        'invoice' => 'Create a polite invoice reminder email...',
        'followup' => 'Generate a friendly follow-up email...',
        'support' => 'Generate a professional support response...',
    ],
];
bash
php artisan vendor:publish --tag=ai-email-assistant-config
bash
php artisan ai-email:generate welcome

config/ai-email-assistant.php