Search code examples
htmlbotframeworkmicrosoft-teams

MS Teams - TaskModule close the window


I display a third party web page(client page) in the task module

  1. using Deeplink https://teams.microsoft.com/l/task/botid?url=https:test.com/test.html&height=450&width=510&title=Custom+Form&completionBotId=botid
  2. new AdaptiveOpenUrlAction() { Title = "Enable MS Team access", Url = new Uri(DeeplinkHelper.DeepLink }

Here the web page is opening in Task module, I need to close this task module by clicking the button available on the web page(URL) and send the result to completionBotId.

Any sample pls that need to implement in client-side code.


Solution

  • There are two steps to make this work:

    1. you need to reference the Teams Javascript SDK in your web page
    2. When your user clicks the button, you would call microsoftTeams.tasks.submitTask in your 'click' event handler. There are a few parameter options for this method, depending on whether you want it to send anything back to your bot. To simply close the window, call microsoftTeams.tasks.submitTask(null);, or if you want to send an object back, call microsoftTeams.tasks.submitTask(whateverObjectYouWantToSendBack);