最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - How to link feedback to the response message in Teams Bot - Bot Framework SDK - Stack Overflow

programmeradmin4浏览0评论

In OnMessageActivityAsync, I am getting an API response, adding feedbackLoop to channelData and calling SendActivityAsync.

 var replyText = $" {APIresponse} ";
 var seperator = "------------------------------------";
 var disclaimerText = "```DisclaimerTextHere```";

 replyText = replyText + "\n\n" + seperator + "\n\n" + disclaimerText;

 var channelData = new JObject
 {
    { "feedbackLoop", new JObject { { "type", "default" } } }
 };

 var messageActivity = MessageFactory.Text(replyText);

 messageActivity.Type = ActivityTypes.Message;
 messageActivity.ChannelData = channelData;

 var resourceResponse = await turnContext.SendActivityAsync(messageActivity, 
 cancellationToken);
 _logger.LogInformation("Resource Response: {0}", resourceResponse.Id);

I am able to get the thumbsup/down icon and also collect the feedback for that message and log it to appinsights in OnInvokeActivityAsync.

 switch (turnContext.Activity.Name)
 {
   case "message/submitAction":
      
     _logger.LogInformation("Your feedback is " + 
     JObject.FromObject(turnContext.Activity.Value).ToString());
  
     _logger.LogInformation("Feedback for message ID: " + 
     turnContext.Activity.ReplyToId);

     var feedbackResponse = new
     {
         status = "success",
         message = "Feedback received"
     };
     return CreateInvokeResponse(200, feedbackResponse);

 default:

     return await base.OnInvokeActivityAsync(turnContext, cancellationToken);
}

I am now trying to link the feedback to the message for which the feedback is given. How can I do that? There is replyToId in OnInvokeActivityAsync and I have confirmed that it matches resourceResponse.Id in OnMessageActivityAsync. But how can I get the message or any attribute that corresponds to the replyToId.

The API response message also comes with an ID from the API endpoint(which I have access to). My ultimate goal is to match that ID that belongs to the incoming API response message to the feedback data and log to app insights. How can I achieve that?

发布评论

评论列表(0)

  1. 暂无评论