This project integrates an Amazon Lex bot into a Laravel application using Filament for the frontend. Users can interact with the Lex bot via predefined intents, and their interactions are logged and displayed on a chat page.After the conversation ends the emotional index will be fetched from the Gemini API
- Users are presented with two random intents from a predefined set.
- Conversations with the bot flow from one intent to the next.
- Once the chat ended the emotional index will be fetched and displayed on chat page
- PHP 8.2+
- Composer
- Laravel 10+
- AWS Account with Lex bot set up
- Filament Admin Panel
-
Clone the repository:
git clone <repository-url> cd <repository-folder>
-
Install dependencies:
composer install npm install && npm run dev
-
Set up environment variables:
Create a
.env
file from the example:cp .env.example .env
Update the
.env
file with your database and AWS and Gemini credentials:AWS_ACCESS_KEY_ID=your-access-key-id AWS_SECRET_ACCESS_KEY=your-secret-access-key AWS_DEFAULT_REGION=your-region AWS_LEX_BOT_NAME=your-bot-name AWS_LEX_BOT_ALIAS=your-bot-alias GOOGLE_API_KEY=your-api-key GEMINI_API_URL=gemini-api-url
-
Run migrations:
php artisan migrate
-
Run the application:
php artisan serve
-
Access the chat page:
Navigate to
http://localhost:8000/chat-page
to start interacting with the Lex bot. -
Submit a message:
The page will start the chat with a random intent.. Once the conversation for the current intent ends, another random intent will be presented.
app/Filament/Pages/ChatPage.php
: The main Filament page class that handles the chat logic.app/Services/LexService.php
: A service class for interacting with the Amazon Lex bot.app/Services/GeminiService.php
: A service class for interacting with Gemini AI for emotional index of the user.resources/views/filament/pages/chat-page.blade.php
: The Blade view for the chat page.app/Models/ChatInteraction.php
: Eloquent model for saving chat interactions.