feat: Add message support for input_select type in Facebook (#11627)
This commit is contained in:
@@ -47,12 +47,29 @@ class Facebook::SendOnFacebookService < Base::SendOnChannelService
|
||||
def fb_text_message_params
|
||||
{
|
||||
recipient: { id: contact.get_source_id(inbox.id) },
|
||||
message: { text: message.content },
|
||||
message: fb_text_message_payload,
|
||||
messaging_type: 'MESSAGE_TAG',
|
||||
tag: 'ACCOUNT_UPDATE'
|
||||
}
|
||||
end
|
||||
|
||||
def fb_text_message_payload
|
||||
if message.content_type == 'input_select' && message.content_attributes['items'].any?
|
||||
{
|
||||
text: message.content,
|
||||
quick_replies: message.content_attributes['items'].map do |item|
|
||||
{
|
||||
content_type: 'text',
|
||||
payload: item['title'],
|
||||
title: item['title']
|
||||
}
|
||||
end
|
||||
}
|
||||
else
|
||||
{ text: message.content }
|
||||
end
|
||||
end
|
||||
|
||||
def external_error(response)
|
||||
# https://developers.facebook.com/docs/graph-api/guides/error-handling/
|
||||
error_message = response['error']['message']
|
||||
|
||||
Reference in New Issue
Block a user