Fix: evaluate automation rules for API-created conversations#277
Open
josephsellers wants to merge 1 commit intoabhinavxd:mainfrom
Open
Fix: evaluate automation rules for API-created conversations#277josephsellers wants to merge 1 commit intoabhinavxd:mainfrom
josephsellers wants to merge 1 commit intoabhinavxd:mainfrom
Conversation
Conversations created via the POST /api/v1/conversations endpoint (e.g. from external integrations, email workers, or form webhooks) were not evaluated against automation rules. Only conversations created through the incoming message flow (IMAP/POP) triggered automation rule evaluation. This adds the missing EvaluateNewConversationRules call to handleCreateConversation, matching the existing behaviour in the incoming message handler (internal/conversation/message.go). [Used Claude Code 🤖]
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
Conversations created via
POST /api/v1/conversations(e.g. from external integrations, email workers, or webhook-based form submissions) are not evaluated against automation rules. Only conversations created through the incoming message flow triggerEvaluateNewConversationRules.This adds the missing call in
handleCreateConversation, matching the existing behaviour in the incoming message handler (internal/conversation/message.go).The bug
In
cmd/conversation.go,handleCreateConversationtriggers the webhook event but does not callEvaluateNewConversationRules:Compare to
internal/conversation/message.go(line 776-782), which does both:The fix
One-line addition after the webhook trigger:
How we found it
We have a
new_conversationautomation rule that auto-closes tickets from known spam domains using thecontainsoperator oncontact_email. It never fired. Tracing through the code, we found that all our inbound tickets arrive via the API (Cloudflare email worker and Gravity Forms webhooks), which bypasses the automation engine entirely.