fix(wuzapi): update webhook events and url for automation
This commit is contained in:
parent
fb4df77b28
commit
39189e2e42
@ -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
|
||||||
|
|||||||
@ -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
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user