How do I change facebook messenger bot webhook?

2019-03-22 09:33发布

问题:

I have successfully implemented a facebook bot. It's working fine. I was trying to change the webhook url now as I have to port it to a different server with a new domain.

There is an option to change the events but I could not find and option to change the webhook. How do I change it?

回答1:

You can't edit the link directy from the "Messenger" product. On the left menu, after selecting your application, you have to click "+ add product" and add also webhooks. From webhooks then you can edit also messenger's webhook.

To edit the webhook, click on Edit Subscription button on the page. Make sure that the dropdown at the top has the option Page selected.



回答2:

You can change webhook under "webhooks" in menu (picture).



回答3:

Besides setting from UI, you can also use subscriptions API to achieve this:

Docs: https://developers.facebook.com/docs/graph-api/reference/app/subscriptions

For example:

POST /v2.12/{app-id}/subscriptions HTTP/1.1
Host: graph.facebook.com

object=page&callback_url=http%3A%2F%2Fexample.com%2Fcallback%2F&fields=about%2C+picture&include_values=true&verify_token=thisisaverifystring

callback_url is what you want to change. Make sure you have correct field and verify_token setting too.