feat: Add a setting to keep conversations pending on bot failures (#13512)
Adds an account-level setting `keep_pending_on_bot_failure` to control whether conversations should move from pending to open when agent bot webhooks fail. Some users experience occasional message drops and don't want conversations to automatically reopen due to transient bot failures. This setting gives accounts control over that behavior. This is a temporary setting which will be removed in future once a proper fix for it is done, so it is not added in the UI.
This commit is contained in:
@@ -36,16 +36,21 @@ class Webhooks::Trigger
|
||||
|
||||
case @webhook_type
|
||||
when :agent_bot_webhook
|
||||
conversation = message.conversation
|
||||
return unless conversation&.pending?
|
||||
|
||||
conversation.open!
|
||||
create_agent_bot_error_activity(conversation)
|
||||
update_conversation_status(message)
|
||||
when :api_inbox_webhook
|
||||
update_message_status(error)
|
||||
end
|
||||
end
|
||||
|
||||
def update_conversation_status(message)
|
||||
conversation = message.conversation
|
||||
return unless conversation&.pending?
|
||||
return if conversation&.account&.keep_pending_on_bot_failure
|
||||
|
||||
conversation.open!
|
||||
create_agent_bot_error_activity(conversation)
|
||||
end
|
||||
|
||||
def create_agent_bot_error_activity(conversation)
|
||||
content = I18n.t('conversations.activity.agent_bot.error_moved_to_open')
|
||||
Conversations::ActivityMessageJob.perform_later(conversation, activity_message_params(conversation, content))
|
||||
|
||||
Reference in New Issue
Block a user