0

If yes, how we will manage endpoints? If no, how to handle multiple dialogues with the same controller?

Nitish
  • 45
  • 8

2 Answers2

1

Yes you can control multiple bots with multiple flows with a single webservice instance.

However you need to create different Bot Framework accounts for each, and use a dynamic url in your webhook.

Example webhook:

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

All of the requests from different bot connectors will hit the same instance and you can differentiate from which bot it is coming using this CUSTOMER_ID parameter.

To bind different dialogs to different bots, you can create multiple builder.ChatConnector instances:

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());

});

This code block is taken from official developer blog, you should read it for further details:

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

As a final note, I should tell that if you aim to configure your bots without restarting your instance, (e.g. a web based platform to configure chat bots flow) you should implement a refresh mechanism.

Information about that sort of mechanism can be found here:

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

SafaOrhan
  • 690
  • 9
  • 19
0

If you would like to use multiple dialogs I suggest you take a look at this post there is also a sample in this repo. It is entirely possible to use multiple dialogs.

D4RKCIDE
  • 3,439
  • 1
  • 18
  • 34
  • I am not talking about dialog. I am talking about controllers. We have all the setup available so why can't we have multiple controllers? – Nitish Aug 27 '17 at 16:54