fix(wuzapi): update webhook events and url for automation

This commit is contained in:
Rodrigo Borba 2026-01-03 17:22:07 -03:00
parent fb4df77b28
commit 39189e2e42
2 changed files with 7 additions and 5 deletions

View File

@ -25,7 +25,9 @@ module Wuzapi
# Host logic needs to come from GlobalConfig or Rails.application.routes # Host logic needs to come from GlobalConfig or Rails.application.routes
# Ideally passed in or resolved. # Ideally passed in or resolved.
base_host = ENV.fetch('FRONTEND_URL', 'http://localhost:3000') base_host = ENV.fetch('FRONTEND_URL', 'http://localhost:3000')
webhook_url = "#{base_host}/webhooks/wuzapi/#{inbox_id}?secret=#{webhook_secret}" inbox = Inbox.find(inbox_id)
phone_number = inbox.channel.phone_number.delete('+')
webhook_url = "#{base_host}/webhooks/whatsapp/#{phone_number}"
@client.set_webhook(user_token, webhook_url) @client.set_webhook(user_token, webhook_url)
end end

View File

@ -62,7 +62,7 @@ module Wuzapi
def set_webhook(user_token, webhook_url) def set_webhook(user_token, webhook_url)
# Wuzapi expects key 'webhook' per documentation. # Wuzapi expects key 'webhook' per documentation.
payload = { 'webhook' => webhook_url, 'events' => ['All'] } payload = { 'webhook' => webhook_url, 'events' => %w[Message ReadReceipt Presence HistorySync ChatPresence] }
request(:post, '/webhook', payload, user_auth_headers(user_token)) request(:post, '/webhook', payload, user_auth_headers(user_token))
end end