c# - Bot Framework logging chat history (With ReplyToActivityAsync - isTyping indicator) -


how save chat conversation of user bot? yes, have seen examples regarding this, didn't worked. did not use builder.update() because obsolete. however, seems have gotten work bot user (same implementation). problem is, right after log chat user bot, bot stops responding (totally no response), bugs me out because if log bot user code still working continuously.

here's code: user bot

 public class usertobotloggerservice : iposttobot {     private readonly iconnectorclient _client;     private readonly imessageactivity _fromuser;     public usertobotloggerservice(imessageactivity fromuser, iconnectorclient client)     {         setfield.notnull(out _fromuser, nameof(fromuser), fromuser);         setfield.notnull(out _client, nameof(client), client);     }     public async task postasync(iactivity activity, cancellationtoken token)     {         var conversation = "";         var convactivity = "";         conversation = $"from: {activity.from.name} \n\n to: {activity.recipient.name} \n\n message: {activity.asmessageactivity()?.text}";         convactivity = convactivity + conversation;          await _client.conversations.replytoactivityasync((activity)activity, token);     } } 

messagecontroller

public messagescontroller()     {         //var builder = new containerbuilder();         conversation.updatecontainer(             builder =>             {                 builder.registertype<usertobotloggerservice>()                 .asimplementedinterfaces()                 .instanceperlifetimescope();                 });       } 

here's other implementation used using iactivitylogger

        public async task logasync(iactivity activity)     {         var conversation = "";         var convactivity = "";         conversation = $"from: {activity.from.name} \n\n to: {activity.recipient.name} \n\n message: {activity.asmessageactivity()?.text}";         convactivity = convactivity + conversation;      }    conversation.updatecontainer(             builder =>             {                 builder.registertype<bottouserloggerservice>()                 .asimplementedinterfaces()                 .instanceperlifetimescope();             } 

thanks! ps: still cannot insert comment in user thread due in need of reputation of @ least 50. pardon me if there duplicates regarding question, in might have seen , tried solution.

edit1: have found bug, seems istyping activity indicator 1 blocking iactivitylogger uses replytoactivityasync per reference! problem istyping activity indicator.

edit2: fixed istyping activity indicator.

i'll update answer.

i inherited iactivityloggerand implemented function ended this

        public async task logasync(iactivity activity)         {             var conversation = "";             var convactivity = "";             conversation = $"from: {activity.from.name} \n\n to: {activity.recipient.name} \n\n message: {activity.asmessageactivity()?.text}";             convactivity = convactivity + conversation;         } 

yes, quite same other issues on how log chat history, however, discovered problem on connector.conversations.replytoactivityasync(message); this doesn't allow hit iactivitylogger, replytoactivityasync did, might in near future.

public async task<httpresponsemessage> post([frombody]activity activity)     {         if (activity.type == activitytypes.message)         {             activity istypingreply = activity.createreply();             istypingreply.type = activitytypes.typing;             handlesystemmessage(istypingreply); //i passed activity type handlesystemmessage , let handle typingactivity;             await conversation.sendasync(activity, () => new yourdialog());         }           else         {             handlesystemmessage(activity);         }         var response = request.createresponse(httpstatuscode.ok);         return response;     } 

handlesystemmessage

else if (message.type == activitytypes.typing)         {             connectorclient connector = new connectorclient(new system.uri(message.serviceurl));             connector.conversations.replytoactivityasync(message);         } 

the handlesystemmessage 1 handling replytoactivityasync wherein miraculously discovered bypasses iactivitylogger limitation, wherein it's has it's own world.


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -