-
Notifications
You must be signed in to change notification settings - Fork 5.1k
fix: integrate Typebot status change events for webhook in chatbot controller e service #1927
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: integrate Typebot status change events for webhook in chatbot controller e service #1927
Conversation
…ntroller and service
Reviewer's GuideThis PR hooks into Typebot session lifecycle events to emit TYPEBOT_CHANGE_STATUS webhooks by importing the new Events enum, constructing a standardized payload, and invoking sendDataWebhook in both the service and controller layers. Sequence diagram for Typebot status change webhook emissionsequenceDiagram
participant TypebotService
participant WAMonitoringService
participant waInstance
participant Webhook
TypebotService->>WAMonitoringService: On session open/close/delete
WAMonitoringService->>waInstance: sendDataWebhook(TYPEBOT_CHANGE_STATUS, typebotData)
waInstance->>Webhook: Emit webhook with status change
Class diagram for updated TypebotService and BaseChatbotControllerclassDiagram
class TypebotService {
-openaiService: OpenaiService
+constructor(waMonitor, configService, prismaRepository, openaiService)
+sendDataWebhook(Events.TYPEBOT_CHANGE_STATUS, typebotData)
}
class BaseChatbotController {
-integrationName: string
+sendDataWebhook(Events.TYPEBOT_CHANGE_STATUS, typebotData)
}
TypebotService --|> BaseChatbotService
BaseChatbotController <|-- ChatbotController
TypebotService o-- WAMonitoringService
TypebotService o-- OpenaiService
TypebotService o-- prismaRepository
BaseChatbotController o-- WAMonitoringService
BaseChatbotController o-- sessionRepository
BaseChatbotController o-- settingsRepository
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes - here's some feedback:
- You’re repeating the same TYPEBOT_CHANGE_STATUS webhook emission logic in multiple branches—consider extracting it into a shared helper or method to DRY up the code.
- Avoid hardcoding status values across the service and controller; centralize them as constants or an enum to ensure consistency and prevent typos.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- You’re repeating the same TYPEBOT_CHANGE_STATUS webhook emission logic in multiple branches—consider extracting it into a shared helper or method to DRY up the code.
- Avoid hardcoding status values across the service and controller; centralize them as constants or an enum to ensure consistency and prevent typos.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
|
||
| const remoteJid = data.remoteJid; | ||
| const status = data.status; | ||
| const status = data.status; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code-quality): Prefer object destructuring when accessing and using properties. (use-object-destructuring)
| const status = data.status; | |
| const {status} = data; |
Explanation
Object destructuring can often remove an unnecessary temporary reference, as well as making your code more succinct.From the Airbnb Javascript Style Guide
|
Please fix the lint with |
Does not trigger webhook for Typebot status change events (TYPEBOT_CHANGE_STATUS)
refactor(chatbot): unify keywordFinish type and enhance session handling
f9567fb
Related to issues:
Status de alteração do Typebot
#1382
Update Typebot Status (http request) session closed or deleted
#1390
Summary by Sourcery
Integrate TYPEBOT_CHANGE_STATUS webhook events into the chatbot flow by emitting session status changes (opened, closed, deleted, paused) from both the Typebot service and the base controller.
New Features: