feat(facebook): use HUMAN_AGENT tag for Messenger replies when human-agent config is enabled (#13690)

This PR updates Facebook Messenger outbound tagging in Chatwoot to
support Human Agent messaging when enabled.

Previously, Facebook outbound text and attachment messages were always
sent with:

```
messaging_type: MESSAGE_TAG
tag: ACCOUNT_UPDATE
```
With this change, the tag is selected dynamically:

```
HUMAN_AGENT when ENABLE_MESSENGER_CHANNEL_HUMAN_AGENT is enabled
ACCOUNT_UPDATE as fallback when the flag is disabled
```
This commit is contained in:
Muhsin Keloth
2026-03-02 15:32:59 +04:00
committed by GitHub
parent ab93821d2b
commit 9aacc0335b
2 changed files with 18 additions and 2 deletions

View File

@@ -7,6 +7,7 @@ describe Facebook::SendOnFacebookService do
allow(Facebook::Messenger::Subscriptions).to receive(:subscribe).and_return(true)
allow(bot).to receive(:deliver).and_return({ recipient_id: '1008372609250235', message_id: 'mid.1456970487936:c34767dfe57ee6e339' }.to_json)
create(:message, message_type: :incoming, inbox: facebook_inbox, account: account, conversation: conversation)
GlobalConfig.clear_cache
end
let!(:account) { create(:account) }
@@ -90,6 +91,17 @@ describe Facebook::SendOnFacebookService do
}, { page_id: facebook_channel.page_id })
end
it 'sends with HUMAN_AGENT tag when ENABLE_MESSENGER_CHANNEL_HUMAN_AGENT is enabled' do
with_modified_env ENABLE_MESSENGER_CHANNEL_HUMAN_AGENT: 'true' do
message = create(:message, message_type: 'outgoing', inbox: facebook_inbox, account: account, conversation: conversation)
described_class.new(message: message).perform
expect(bot).to have_received(:deliver).with(
hash_including(tag: 'HUMAN_AGENT'),
{ page_id: facebook_channel.page_id }
)
end
end
it 'if message is sent with multiple attachments' do
message = build(:message, content: nil, message_type: 'outgoing', inbox: facebook_inbox, account: account, conversation: conversation)
avatar = message.attachments.new(account_id: message.account_id, file_type: :image)