feat: Add AI chatbot with Prism and schedule functionality#40
Merged
Conversation
- Upgrade Laravel to v11 (required for Prism) - Install echolabsdev/prism package for LLM integration - Add OpenRouter provider configuration - Create ChatController with tools: - list_pets, get_pet, create_pet - list_medications, create_medication - get_upcoming_medications - Add /api/chat and /api/chat/stream endpoints
- Add user_id to Medicacao fillable to persist user association - Map species to especie_id when creating pets via LLM tool
- Add whatsapp_accounts table migration and model
- Create EvolutionApiService wrapper for API calls
- Add webhook controller to handle Evolution events:
- MESSAGES_UPSERT: process incoming messages
- CONNECTION_UPDATE: track instance status
- QRCODE_UPDATED: update QR code
- Integrate webhook with Prism chatbot for AI responses
- Add WhatsApp account management endpoints:
- CRUD operations for instances
- Refresh QR code, logout, delete
- Add Evolution API config (base_url, key)
- Add routes: /api/webhooks/evolution/{instance}, /api/whatsapp
- Remove account CRUD (managed externally via Evolution panel) - Add webhook key security (x-webhook-key header) - Find user by phone number from incoming message - Add EVOLUTION_SETUP.md with setup instructions - Simplify connection update handlers (just log, no DB)
- Remove evolution config from services.php - Inline sendReply method instead of using EvolutionApiService - Keep only EVOLUTION_WEBHOOK_KEY for webhook security
Multi-stage build with nginx + php-fpm + supervisor, matching the truckwise deployment pattern. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The composer.lock was generated with PHP 8.4 dependencies (symfony/filesystem v8.0.9 requires PHP >=8.4). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Prism v0.100.1 doesn't have a Transporter enum, causing package:discover to fail in CI. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Covers UserController, EspacoController, ChatController, and EvolutionWebhookController to push coverage above 50%. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Tool::as() is not static in Prism v0.100.1, use (new Tool)->as() - findUserByPhone now queries WhatsappAccount instead of non-existent phone column on users table Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace withOptionalStringParameter() with withStringParameter(required: false) - Both ChatController and EvolutionWebhookController affected Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Decode JSON body before checking for unicode string content. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Policy tests for Pet and Medicacao - Model relation tests - UserObserver test - Facebook auth integration test - Google auth route test Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- EspacoController store/update tests - EspacoPolicy unit test - Webhook processMessage test with Prism fake Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…igration - Replace $request->validated() with validate()+only() in EspacoController - Fix whatsapp_accounts migration to use UUID primary key to match HasUuids Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #40 +/- ##
==========================================
- Coverage 58.33% 56.01% -2.33%
==========================================
Files 40 44 +4
Lines 240 632 +392
==========================================
+ Hits 140 354 +214
- Misses 100 278 +178 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
echolabsdev/prismpackage for LLM integrationconfig/prism.phplist_pets- List all user's petsget_pet- Get pet details by namecreate_pet- Add a new petlist_medications- List medications (optionally filtered by pet)create_medication- Add medication reminderget_upcoming_medications- Show next 24h of remindersPOST /api/chat- Regular chat responsePOST /api/chat/stream- Streaming responseNext Steps
.env: