简体   繁体   中英

Intercepting outgoing activities in Virtual Assistant Template Botframework

I'm looking for a place inside a Microsoft Bot code (created with the Virtual Assistant Template 4.9.1.1) where I can be able to intercept any outgoing activity just before it is sent from the bot to the client.

As I understood one solution could be to override these two methods in DefaultAdapter:

bool CanProcessOutgoingActivity(Activity activity)

Task<ResourceResponse> ProcessOutgoingActivityAsync(ITurnContext turnContext, Activity activity, CancellationToken cancellationToken)

Since I just have to do some changes to the activity, I thought I could do it directly in the CanProcessOutgoingActivity. But I was wrong since I also need some info from the context.

So I had CanProcessOutgoingActivity() just returning true and move the logic in ProcessOutgoingActivityAsync, where all the info are available.

However I don't understand how it is supposed to work and what the method should return in the ResourceResponse parameter.

Is there any example or documentation from which I can understand how does it works?

Middleware would be the recommended and most straightforward (not to mention modular) approach. It is designed for this type of scenario and should accomplish what you need.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM