How to open an Internet tab in the Microsoft Bot framework server side?

Viewed 218

I need to open a url tab when the user clicks an action.submit on an adaptive card. I do not want to user Action.OpenURL. In the OnEvent method, i would like to add some code to open a internet tab on the client side. Is it possible to open a tab in the client side (MICROSOFT TEAMS) from the server side within the Microsoft Bot framework? If yes, how could i do it in C#.

1 Answers

It is common to want to combine a submit action and an open-URL action in one button, so that the bot receives an activity when the user opens a page. Since no cards support double actions, there are a few ideas to explore when trying to get this to work:

  1. Use a submit action and then have the bot send an activity back to the channel that makes a page open automatically
  2. Use an open-URL action and then have the URL access the bot

The first idea is impossible unless you're using Web Chat because there aren't any activities that make a client open a URL, and if you're using Web Chat then you might as well extend it to support double actions.

For the second idea, there are a few ways to go about it. You could host a separate API that sends an activity to the bot or you could have the URL be in the bot's own domain and have it call the bot code directly. In any case, once the bot is notified about the action you'll want the user to be redirected to the actual page you want them to see. There's an example of that here: https://github.com/EricDahlvang/OpenUrlRedirectBot

Related