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

%3CLINGO-SUB%20id%3D%22lingo-sub-1156166%22%20slang%3D%22en-US%22%3EMessaging%20Extension%3A%20task%20used%20to%20show%20a%20web%20page.%20Close%20with%20result%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1156166%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EI%20have%20a%20Teams%20app%20with%20a%20bot%20and%20I%20have%20added%20message%20extension%2C%20to%20display%20a%20custom%20web%20in%20a%20popup%20when%20the%20new%20command%20is%20selected.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20created%20an%20%22action%22%20command%20with%20%22dynamic%20set%20of%20params%22.%20With%20that%2C%20my%20bot%20receives%20a%20composeExtension%2FfetchTask'%20event%2C%20and%20I%20return%20a%20task%3A%3C%2FP%3E%3CP%3E%3CBR%20%2F%3Ereturn%20%7B%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20task%3A%20%7B%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20type%3A%20'continue'%2C%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20value%3A%20%7B%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20width%3A%20500%2C%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20height%3A%20500%2C%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20title%3A%20'myTitle'%2C%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20url%3A%20%5BmyURL%5D%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWith%20that%2C%20my%20web%20is%20displayed%20in%20the%20popup%20window%20as%20I%20need.%20Ok%2C%20but%26nbsp%3BI%20have%202%20doubts%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E1.%20If%20I%20set%20my%20url%20in%20the%20task%20creation%20(bot%20code)%2C%20where%20is%20used%20the%20URL%20I%20set%20in%20the%20'Task%20Information'%20in%20the%20Message%20Extension%20creation%20(app)%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E2.%20I%20can%20close%20the%20popup%20with%20'microsoftTeams.tasks.submitTask()'%2C%20but%20is%20it%20possible%20to%20notify%20my%20bot%20about%20the%20result%3F%20I%20can%20send%20a%20request%20before%20closing%2C%20but%20maybe%20both%20thinks%20can%20be%20done%20in%20a%20single%20call.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20in%20advance%2C%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EDiego%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1156166%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1158094%22%20slang%3D%22en-US%22%3ERe%3A%20Messaging%20Extension%3A%20task%20used%20to%20show%20a%20web%20page.%20Close%20with%20result%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1158094%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F402611%22%20target%3D%22_blank%22%3E%40diegoSpace%3C%2FA%3E%2C%26nbsp%3BWhen%20you%20use%20%22%3CSPAN%3EmicrosoftTeams.tasks.submitTask()%22%2C%20you%20receive%20a%20task%20module%20submit%20request%20in%20bot%20code%20%22OnTeamsTaskModuleSubmitAsync()%22.%20You%20write%20code%20inside%20the%20method%20to%20handle%20submit%20request.%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1171640%22%20slang%3D%22en-US%22%3ERe%3A%20Messaging%20Extension%3A%20task%20used%20to%20show%20a%20web%20page.%20Close%20with%20result%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1171640%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F451628%22%20target%3D%22_blank%22%3E%40subhasish-MSFT%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ethanks%20for%20your%20response.%3C%2FP%3E%3CP%3EI%20receive%20a%20'fetchTask'%20event%20and%20I%20return%20a%20web%20page%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BhandleTeamsMessagingExtensionFetchTask(context%2C%20action)%20%7B..%7D%3CBR%20%2F%3EThis%20page%20is%20displayed%20in%20the%20Teams%20browser%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20I%20want%20to%20open%20a%20new%20web%20from%20this%20page%20(for%20instance%20when%20a%20button%20is%20pressed)%2C%20must%20I%20create%20a%20task%20in%20the%20web%20page%20and%20call%20'microsoftTeams.tasks.submitTask()'%3F%20Will%20it%20be%20received%20in%20bot%20code%3F%20I%20tried%20with%20this%20method%20i%20found%20in%20docu%20but%20no%20event%20arrives%3A%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BhandleTeamsMessagingExtensionSubmitAction(context%2C%20action)%20%7B..%7D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20get%20an%20exception%3A%20%22%22DataCloneError%3A%20Failed%20to%20execute%20'postMessage'%20on%20'Window'...%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOr%20the%20task%20must%20be%20created%20in%20the%20bot%20(like%20the%201st%20one%20I%20returned%20properly%20when%20the%20'fetchTask'%20event%20is%20received)%3F%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EIn%20this%20case%2C%20how%20can%20I%20call%20from%20my%20current%20task%20(web%20page)%3F%3C%2FP%3E%3CP%3EI%20am%20afraid%20I'm%20not%20sure%20about%20the%20behaviour%20(submitTask%2FstartTask%2F...)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnother%20question%3A%20Teams%20browser%20window%20can%20not%20be%20resized%2C%20correct%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%3CBR%20%2F%3EDiego%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1172172%22%20slang%3D%22en-US%22%3ERe%3A%20Messaging%20Extension%3A%20task%20used%20to%20show%20a%20web%20page.%20Close%20with%20result%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1172172%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F451628%22%20target%3D%22_blank%22%3E%40subhasish-MSFT%3C%2FA%3E%26nbsp%3BHi%2C%20thanks%20for%20your%20response.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENow%20I%20receive%20an%20event%20in%20my%20bot%20('handleTeamsMessagingExtensionSubmitAction'%20method)%20with%20the%20taskInfo%20from%20the%20web%20page%20(for%20instance%20when%20a%20button%20is%20pressed)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhen%20I%20receive%20this%20event%20I%20need%20to%20change%20the%20web%20page%20displayed%20(new%20content%2C%20new%20window%20size)%2C%20so%20I%20return%20a%20new%20task%20in%20this%20bot%20method%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20works%20properly%20in%20Teams%20web%20('page2.html'%20is%20loaded%2C%20so%20window%20size%20is%20increased)%3CBR%20%2F%3EBUT%20it%20does%20not%20work%20for%20me%20in%20Teams%20desktop%20('page2.html'%20is%20loaded%20but%20window%20height%20flicks%3A%20150%20-%26gt%3B%20250%20-%26gt%3B%20150)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20happens%20the%20same%20if%202nd%20page%20is%20smaller%20or%20bigger%20than%201st%20(flick%20and%20back%20to%20size%20of%20page%201)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMy%20code%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EhandleTeamsMessagingExtensionFetchTask(context%2C%20action)%20%7B%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20return%20%7B%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20task%3A%20%7B%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20type%3A%20'continue'%2C%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20value%3A%20%7B%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20width%3A%20500%2C%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20height%3A%20150%2C%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20title%3A%20%22Page%201%22%2C%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20url%3A%20'page1.html'%2C%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20fallbackUrl%3A%20'page1.html'%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%7D%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%7D%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3EhandleTeamsMessagingExtensionSubmitAction(context%2C%20action)%20%7B%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20return%20%7B%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20task%3A%20%7B%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20type%3A%20'continue'%2C%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20value%3A%20%7B%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20width%3A%20500%2C%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20height%3A%20250%2C%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20title%3A%20%22Page%202%22%2C%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20url%3A%20'page2.html'%2C%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20fallbackUrl%3A%20'page2.html'%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%7D%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%7D%3B%3CBR%20%2F%3E%7D%3CBR%20%2F%3EThanks%2C%3CBR%20%2F%3EDiego%3C%2FP%3E%3C%2FLINGO-BODY%3E
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