IBotContext information lost upon thread switches
See original GitHub issueHi,
Last few days I’ve been trying out a few things with the new botbuilder SDK. I’m using Akka.NET to implement my dialog flow. I really like Akka.NET because I can easily implement an actor based on the finite state machine pattern to model different stages of the conversation that my bot is in.
I noticed however that when I pass the IBotContext as a message to my Akka actor information is lost and the call ReplyToActivity
on IBotContext doesn’t result in a message to the user of my bot.
I’m curious what happens with the IBotContext object when I pass it to another thread. Could it be that information is lost when I do this?
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
c# - Thread Context Switching Issue
The problem with this threading, I believe, is that the context switching between the threads is causing enough time (a very small amount...
Read more >Am I missing something obvious, or is there really no ...
A Thread mesh network based on mains-powered light switches would be awesome. Then again, I'm getting to have so many HomePod Minis in...
Read more >Trouble With New Eve Light Switch (3rd Gen, Thread)
I installed the new Eve light switch today in a three-way set up. Physically using the switches results in normal, expected behavior.
Read more >Eve Light Switch | evehome.com
Enjoy the convenience of connected lighting with Eve Light Switch without replacing a single bulb in your home. Turn your lights on or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here’s the code that I wrote: https://github.com/wmeints/bot-actors-sample
I think I have time to extend the sample further tomorrow. Probably going to add stuff around LUIS and QnaMaker so that it becomes a real example 😃
DISCLAIMER: I’m familiar with a couple of actor systems and the actor model in general, but not steeped in Akka.NET specifically.
First, to make sure I’m understanding you correctly, you’re trying to pass the
IBotContext
through to your actor via a message, correct? If so, I’m relatively certain that’s not going to work. Actor messages are meant to essentially be POCOs that get serialized, sent to a mailbox (in Akka.NET’s case) and then delivered to an actor “in time”. WhileIBotContext
is technically thread safe, it is not able to be serialized and “remoted” in this this way. Besides, it would be violating the rule of passing a mutable object to an actor which is frowned upon.You also wouldn’t be able to inject it via Akka.NET “props” because the props are only resolved when an actor instance is created and if that actor “lives” throughout many activity messages from the bot framework perspective, it would need to be working with the proper
IBotContext
for each of those messages.I do actually think actor systems are potentially a really good match for implementing bots, I just don’t think the current abstractions of the v4 SDK as it stands right now are going to “fit” that kind of system naturally due to the major architectural differences actor systems present from a traditional application architectures. It would not be a stretch to imagine a more native SDK for Akka.NET (or other actor systems) at some point in the future, but, full disclosure, I’m not on the product team so I’m not promising anything. 😄
Anyway, let’s think… how could you do this right now? 🤔 I assume right now you are using some sort of API gateway leveraging ASP.NET, resolving an
ActorRef
and that’s when you tried to send it over theIBotContext
via aTell
based message… maybe? Spitballing here: what if, instead of sending over theIBotContext
itself, you sent over only theActivity
and maybe even your state, but you do so with anAsk
and then your API gateway awaits that, takes the result of theAsk
, which would be a respone message with maybeList<Activity>
and your state again, and marshals those back onto theIBotContext
???