1 回答
TA贡献1829条经验 获得超6个赞
如果您想参与从机器人从一个中间件向外发送的活动的中间,您需要ITurnContext::OnSendActivities像这样挂钩:
public class MyActivityLoggingMiddleware : IMiddleware
{
public async Task OnTurnAsync(ITurnContext turnContext, NextDelegate next, CancellationToken cancellationToken = default(CancellationToken))
{
// log incoming activity from turnContext.Activity here
// Hook the turn context's OnSendActivities
turnContext.OnSendActivities(HandleSendActivities);
await next(cancellationToken);
}
private async Task<ResourceResponse[]> HandleSendActivities(ITurnContext turnContext, List<Activity> activities, Func<Task<ResourceResponse[]>> next)
{
// log activities being sent here
return await next();
}
}
- 1 回答
- 0 关注
- 85 浏览
添加回答
举报