1 回答

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超6個(gè)贊
如果您想?yún)⑴c從機(jī)器人從一個(gè)中間件向外發(fā)送的活動(dòng)的中間,您需要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 關(guān)注
- 104 瀏覽
添加回答
舉報(bào)