Messaging Extension: task used to show a web page. Close with result?

Contributor

Hi,

I have a Teams app with a bot and I have added message extension, to display a custom web in a popup when the new command is selected.

 

I created an "action" command with "dynamic set of params". With that, my bot receives a composeExtension/fetchTask' event, and I return a task:


return {
      task: {
      type: 'continue',
      value: {
      width: 500,
      height: 500,
      title: 'myTitle',
      url: [myURL]
      ...

 

With that, my web is displayed in the popup window as I need. Ok, but I have 2 doubts:

 

1. If I set my url in the task creation (bot code), where is used the URL I set in the 'Task Information' in the Message Extension creation (app)?

 

2. I can close the popup with 'microsoftTeams.tasks.submitTask()', but is it possible to notify my bot about the result? I can send a request before closing, but maybe both thinks can be done in a single call.

 

Thanks in advance,


Diego

2 Replies

@diegoSpace, When you use "microsoftTeams.tasks.submitTask()", you receive a task module submit request in bot code "OnTeamsTaskModuleSubmitAsync()". You write code inside the method to handle submit request.  

@subhasish-MSFT Hi, thanks for your response.

 

Now I receive an event in my bot ('handleTeamsMessagingExtensionSubmitAction' method) with the taskInfo from the web page (for instance when a button is pressed)

 

When I receive this event I need to change the web page displayed (new content, new window size), so I return a new task in this bot method

 

It works properly in Teams web ('page2.html' is loaded, so window size is increased)
BUT it does not work for me in Teams desktop ('page2.html' is loaded but window height flicks: 150 -> 250 -> 150)

 

It happens the same if 2nd page is smaller or bigger than 1st (flick and back to size of page 1)

 

My code:

 

handleTeamsMessagingExtensionFetchTask(context, action) {
    return {
            task: {
                  type: 'continue',
                  value: {
                  width: 500,
                  height: 150,
                  title: "Page 1",
                  url: 'page1.html',
                  fallbackUrl: 'page1.html'
          }
     };
}

handleTeamsMessagingExtensionSubmitAction(context, action) {
    return {
            task: {
                  type: 'continue',
                  value: {
                  width: 500,
                  height: 250,
                  title: "Page 2",
                  url: 'page2.html',
                  fallbackUrl: 'page2.html'
          }
     };
}
Thanks,
Diego