我们可以在 Microsoft bot 框架中拥有多个控制器吗?

Can we have multiple controllers in Microsoft bot framework?

如果是,我们将如何管理端点? 如果不是,如何处理同一个控制器的多个对话?

如果您想使用多个对话框,我建议您看看 there is also a sample in this repo。完全可以使用多个对话框。

是的,您可以使用单个 Web 服务实例控制具有多个流的多个机器人。

但是您需要为每个帐户创建不同的 Bot Framework 帐户,并在您的 webhook 中使用动态 url。

网络钩子示例:

https://my-bot-controller-service.com/api/CUSTOMER_ID/messages

来自不同机器人连接器的所有请求都将命中同一个实例,您可以使用此 CUSTOMER_ID 参数区分它来自哪个机器人。

要将不同的对话框绑定到不同的机器人,您可以创建多个 builder.ChatConnector 实例:

var customersBots = [
  { cid: 'cid1', appid: '', passwd: '' }, 
  { cid: 'cid2', appid: '', passwd: '' }, 
  { cid: 'cid3', appid: '', passwd: '' }, 
];

// expose a designated Messaging Endpoint for each of the customers
customersBots.forEach(cust => {

  // create a connector and bot instances for 
  // this customer using its appId and password
  var connector = new builder.ChatConnector({
    appId: cust.appid,
    appPassword: cust.passwd
  });
  var bot = new builder.UniversalBot(connector);

  // bing bot dialogs for each customer bot instance
  bindDialogsToBot(bot, cust.cid);

  // bind connector for each customer on it's dedicated Messaging Endpoint.
  // bot framework entry should use the customer id as part of the
  // endpoint url to map to the right bot instance
  app.post(`/api/${cust.cid}/messages`, connector.listen());

});

此代码块来自官方开发者博客,您应该阅读以了解更多详细信息:

https://www.microsoft.com/developerblog/2017/01/10/creating-a-single-bot-service-to-support-multiple-bot-applications/

最后一点,我要说的是,如果您打算在不重新启动实例的情况下配置您的机器人(例如,基于 Web 的平台来配置聊天机器人流程),您应该实施刷新机制。

有关此类机制的信息可在此处找到:

https://www.microsoft.com/developerblog/2016/12/12/integrating-an-existing-bot-platform-with-microsofts-bot-framework/