如何将单个Webhook用于多个Messenger应用/机器人? [英] How to use a single webhook for multiple messenger apps/bots?

查看:200
本文介绍了如何将单个Webhook用于多个Messenger应用/机器人?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为不同的fb页面开发不同的聊天机器人,但是我只有一台服务器来运行它们.

I'm developing different chatbots for different fb pages but I only have one server to run them.

对于第一个聊天机器人,我将https://mydomain/webhook用作webhook,并且一切正常,所有消息均发送到443 port,然后我的程序对其进行处理.现在,我想知道第二个聊天机器人应该使用什么网络挂钩.我的想法是在另一个端口上打开https连接,并使用https://mydomain/webhook:myport作为webhook,以便每个漫游器在不同的端口上侦听,并且每个webhook都指向它们.

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.

不幸的是,当我尝试从facebok开发人员平台验证我的Webhook时,得到了404 not found响应.我还尝试在相同的端口(443)上使用相同的Webhook,并且得到403 forbidden响应.

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.

推荐答案

您可以为多个facebook Messenger机器人使用完全相同的Webhook,相同的端口以及所有端口.发送到您的Webhook的消息传递事件的每个有效负载都将被分类到该消息所针对的页面列表中.您可以编写代码来处理每个页面的有效载荷,以防它们撞上Webhook.

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.

这篇关于如何将单个Webhook用于多个Messenger应用/机器人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆