问题
I'm developing different chatbots for different fb pages but I only have one server to run them.
For the first chatbot I am using https://mydomain/webhook
as webhook and everything works fine, all the messages are sent to the 443 port
and my program process them. Now I was wondering what should be the webhook for my second chatbot. My idea was to open a https connection on another port and use https://mydomain/webhook:myport
as webhook so that each bot listen on a different port and each webhook points to them accordingly.
Unfortunately when I try to validate my webhook from the facebok developer platform I got a 404 not found
response. I also tried to use the same webhook on the same port (443) and I get 403 forbidden
response.
回答1:
You can use the exact same webhook, same port and all, for multiple facebook messenger bots. Each payload of messaging events sent to your webhook will be sorted into a list of pages that the messages are for. You can write code to handle each page's payload differently after it has hit your webhook.
回答2:
My error was to add the port number after "/webhook" while the port number should go after the ip address "https://mydomain". In case anyone else was wondering, yes you can use the same webhook for different messenger apps, just use different ports.
回答3:
You can receive your response in 443 and then redirect to your specified port by using proxy pass in your server's conf.
server {
listen 443;
server_name mydomain/webhook2;
location /{
proxy_pass http://127.0.0.1:yourportname;
}
}
来源:https://stackoverflow.com/questions/43818793/how-to-use-a-single-webhook-for-multiple-messenger-apps-bots