0

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.

Diagram of Current vs Future interaction between services

Iris Dan
  • 3
  • 2
  • Can you please elaborate on your scenario more. How is the task module being launched? What are you wanting to do, roughly, on it's completion (e.g. proactively send a message to a channel)? – Hilton Giesenow Sep 21 '22 at 06:39
  • @HiltonGiesenow Just updated the post with more details at the bottom. This may or may not be feasible but would save a lot of time and effort if there was a way to do this. Thanks! – Iris Dan Sep 21 '22 at 13:13
  • Why do you want to do this in the first place? – AP01 Sep 21 '22 at 17:01
  • @AP01 Service A knows which region the customer's data will reside in and will send the request to Service B in that region for the customer. Service A and Service B only communicates through a queue. We figured out how to do this for other types of activities like messages but task modules are the last bit of blocker on this implementation. Not the end of the world if this can't be done, but if there was a way to achieve this, it would be the option that requires the least amount of change. – Iris Dan Sep 21 '22 at 17:20
  • Thanks for the update, getting a better picture now, but I'm still struggling to understand what kind of action you're wanting to happen after completion, that you're wanting to "send back". For instance, is it a message to the user in some way? If so, what way? A bot? It's relevant to help guide the answer. – Hilton Giesenow Sep 22 '22 at 05:39
  • @HiltonGiesenow So the user's journey would be 1) user clicks on a messaging extension button 2) a form pops up in a modal 3) user fills out this form and clicks on submit 4) modal closes and user sees an adaptive card in the chat with the content of what they have submitted. The difficulty is in between step 1 and 2 since I don't know how to update the modal with the form the user has requested without having access to the original TurnContext in Service B. I'll try to draw a diagram :) – Iris Dan Sep 22 '22 at 15:41
  • When you launch your message extension in (1), you get the context, which includes the message that triggered the extension. From that, you can pass querystring parameters to your modal - that might give you what you need (pending further clarification) – Hilton Giesenow Sep 23 '22 at 06:52
  • @HiltonGiesenow oh I see. I can start with this. Thank you!! – Iris Dan Sep 26 '22 at 21:55
  • ok great, glad to help. I'll put it as a proper answer below, then please upvote/mark as answer so others with a similar question in future can see this was helpful (it's a bit lost here in comments). Please be sure to keep me updated though, if you come right or still need help. – Hilton Giesenow Sep 27 '22 at 16:47
  • I don't have enough points for upvote so just accepted as the answer. Thank you so much! – Iris Dan Sep 29 '22 at 13:53
  • that's great, thank you. Did you come right with this yet? – Hilton Giesenow Sep 29 '22 at 13:57

1 Answers1

0

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.

Hilton Giesenow
  • 9,809
  • 2
  • 10
  • 24