1

I am creating a message extension in Microsoft teams and I am running into some issues with chaining task modules from the CommandBar (This is the important part)

I have 2 task modules, A and B.

The Goal: Run a command from the CommandBar that will respond with task module A. On submitting the task module the message extension should respond task module B.

The issue: I can't work out how to respond with a task module from inside the onSubmitAction function (on the message extension implementing IMessagingExtensionMiddlewareProcessor.

Here is a cut down version of my code:

export default class HelpDeskMessageExtension implements IMessagingExtensionMiddlewareProcessor {


    public async onFetchTask(): Promise<MessagingExtensionResult | TaskModuleContinueResponse | TaskModuleMessageResponse> {
        return Promise.resolve<TaskModuleContinueResponse>({
            type: "continue",
            value: {
                url: `${process.env.HostName}/helpdesk.html`,
                width: 500,
                height: 500,
            },
        });
    }


    public async onSubmitAction(context: TurnContext): Promise<any> {
        //TODO: If this submit came from task module A, respond with Task module B 

        // If this came from task module B, respond with a success card
        const heroCard = CardFactory.heroCard('<span style="color: green">Message successfully sent</span>',);
        await context.sendActivity({ attachments: [heroCard] });
    }

}

Note: This works fine when using the message extension from the compose box. The issue is running this extension from the CommandBar

Any help would be greatly appreciated.

Ghojzilla
  • 311
  • 1
  • 14
  • Hi @Ghojzilla - Can you please confirm if you have added commandBox as an context in the manifest. – Mamatha-MSFT Mar 16 '21 at 04:19
  • Hi @Ghojzilla, Could you please let us know any update on this. – Sridevi-MSFT Mar 19 '21 at 04:40
  • Hi, sorry I missed this. I found the issue and it was nothing to do with the MS bot framework. I was using a npm package called botbuilder-teams-messagingextensions which I stupidly thought was part of MS bot framework. The package was wrapping any response object from the submit action in a "composeExtension" property so I couldn't wrap it in a task. (Hopefully that makes sense, I'm sending this on my phone with a baby hanging off me!) Thanks again for the response :) – Ghojzilla Mar 20 '21 at 08:19

1 Answers1

1

Posting the Answer for better knowledge Copying from @Ghojzilla comments. I was using a npm package called botbuilder-teams-messagingextensions which I thought was part of MS bot framework. The package was wrapping any response object from the submit action in a "composeExtension" property so I couldn't wrap it in a task.

Sridevi-MSFT
  • 240
  • 1
  • 4