chore: Support Whatsapp Interactive messages (360Dialog) (#3751)
Render button and list reply clicks as text messages in agent dashboard fixes: #3684
This commit is contained in:
@@ -13,7 +13,7 @@ class Whatsapp::IncomingMessageService
|
||||
return if params[:messages].blank?
|
||||
|
||||
@message = @conversation.messages.build(
|
||||
content: params[:messages].first.dig(:text, :body),
|
||||
content: message_content(params[:messages].first),
|
||||
account_id: @inbox.account_id,
|
||||
inbox_id: @inbox.id,
|
||||
message_type: :incoming,
|
||||
@@ -26,6 +26,13 @@ class Whatsapp::IncomingMessageService
|
||||
|
||||
private
|
||||
|
||||
def message_content(message)
|
||||
# TODO: map interactive messages back to button messages in chatwoot
|
||||
message.dig(:text, :body) ||
|
||||
message.dig(:interactive, :button_reply, :title) ||
|
||||
message.dig(:interactive, :list_reply, :title)
|
||||
end
|
||||
|
||||
def account
|
||||
@account ||= inbox.account
|
||||
end
|
||||
@@ -70,7 +77,7 @@ class Whatsapp::IncomingMessageService
|
||||
|
||||
def attach_files
|
||||
message_type = params[:messages].first[:type]
|
||||
return if message_type == 'text'
|
||||
return if %w[text interactive].include?(message_type)
|
||||
|
||||
attachment_payload = params[:messages].first[message_type.to_sym]
|
||||
attachment_file = Down.download(inbox.channel.media_url(attachment_payload[:id]), headers: inbox.channel.api_headers)
|
||||
|
||||
Reference in New Issue
Block a user