Added support for Telegram Business bots. Telegram webhooks from such bots include the business_message field, which we transform into a standard message for Chatwoot. This PR also modifies how we handle replies, attachments, and image uploads when working with Telegram Business bots. demo: https://drive.google.com/file/d/1Yz82wXBVRtb-mxjXogkUju4hlJbt3qyh/view?usp=sharing&t=4 Fixes #10181
This commit is contained in:
@@ -71,6 +71,7 @@ class Telegram::SendAttachmentsService
|
||||
HTTParty.post("#{channel.telegram_api_url}/sendMediaGroup",
|
||||
body: {
|
||||
chat_id: chat_id,
|
||||
**business_connection_body,
|
||||
media: attachments.map { |hash| hash.except(:attachment) }.to_json,
|
||||
reply_to_message_id: reply_to_message_id
|
||||
})
|
||||
@@ -108,6 +109,7 @@ class Telegram::SendAttachmentsService
|
||||
HTTParty.post("#{channel.telegram_api_url}/sendDocument",
|
||||
body: {
|
||||
chat_id: chat_id,
|
||||
**business_connection_body,
|
||||
document: file,
|
||||
reply_to_message_id: reply_to_message_id
|
||||
},
|
||||
@@ -135,4 +137,14 @@ class Telegram::SendAttachmentsService
|
||||
def channel
|
||||
@channel ||= message.inbox.channel
|
||||
end
|
||||
|
||||
def business_connection_id
|
||||
@business_connection_id ||= channel.business_connection_id(message)
|
||||
end
|
||||
|
||||
def business_connection_body
|
||||
body = {}
|
||||
body[:business_connection_id] = business_connection_id if business_connection_id
|
||||
body
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user