diff --git a/app/models/message.rb b/app/models/message.rb index 3be04c54f..275b8b4c1 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -310,10 +310,11 @@ class Message < ApplicationRecord def execute_after_create_commit_callbacks # rails issue with order of active record callbacks being executed https://github.com/rails/rails/issues/20911 reopen_conversation + open_conversation_on_human_response set_conversation_activity dispatch_create_events send_reply - execute_message_template_hooks + execute_message_template_hooks unless human_response? || activity? update_contact_activity end @@ -389,6 +390,13 @@ class Message < ApplicationRecord reopen_resolved_conversation if conversation.resolved? end + def open_conversation_on_human_response + return unless human_response? + return unless conversation.pending? + + conversation.open! + end + def reopen_resolved_conversation # mark resolved bot conversation as pending to be reopened by bot processor service if conversation.inbox.active_bot?