I'm wondering if there is a way to asynchronously respond to MS Teams Task module fetch events. By asynchronous I mean that we would lose the original context of the request because we sent the original request to another service. So one service to receive the requests and another to actually process the events.
I tried to build a new context using TurnContext.getConversationReference
along with TurnContext.SendActivity
. While this successfully sent the "continue" task module body using the original turnContext, it didn't work using the new context that I created with conversation reference.
// Service A - simply ack the request and formats and enqueues the request to a queue
const conversationReference = TurnContext.getConversationReference(context.activity);
// send this conversationReference as part of the payload to another service
// Service B - dequeues from the queue and processes the request
await botFrameworkAdapter.continueConversation(conversationReference, async (newContext) => {
const response = await newContext.sendActivity({
type: "invokeResponse",
value: { status: 200, body: taskCardResponse },
});
});
Task module is being launched through when a user clicks on a messaging extension. When this is launched, messaging extension task fetch is triggered. The backend then returns a form in task module for the user to fill out and submit.
This is the original implementation and in the new approach, we can't simply return the form to the modal because we don't have access to the original request in the service B.
Per the discussion in comments above, the code in the bot to launch the message extension can simply pass via querystring anything that is needed to actual web content page that is launched, and it can do whatever is necessary with what it receives.