Why do messages addressed to a user with conversation id not appear immediately to that user?
User1 is in an active conversation with a bot.
Let's say some instance of the bot sends a message to User1 with the active conversation id.
That message is not presented to user1 unless he messages the bot again, upon which both the bot's response and the sent message are printed to the user
(observed on webchat)
Edit:
Example: Bot sends "Testing message"
User sees nothing
User sends bot "Hello"
Response:
"Testing message"
"Hi! I'm a bot"
Are you using C# or node.js?
I'm using C#
@chrimc62 Another attempt at explaining:
User 1 talks to bot which messages User 2 on conversation Y, what happens is User 2 doesn't see anything. But when User 2 talks to the bot, both the User 1 message and the bot's response appear on screen for User 2 as a response. I've edited the question to explain it better.
What version of the SDK are you running?
@chrimc62 Bot Builder is v1.2.2 Bot connector is v1.1.0
@chrimc62 I've narrowed the issue down to the fact that the message sent to that conversationId is printed whenever the next context.Wait is called on the corresponding bot instance, and not before that
@chrimc62 Context.Wait suspends the bot, perhaps that is why it's not able to send the message to webchat?
@vaditya04 I think the phenomenon you're seeing is explained by this code:
https://github.com/Microsoft/BotBuilder/blob/develop/CSharp/Library/Dialogs/BotToUser.cs#L81
we save one message to return inline with the incoming http request to the bot. If you want to send messages immediately, I would use this other implementation:
https://github.com/Microsoft/BotBuilder/blob/develop/CSharp/Library/Dialogs/BotToUser.cs#L112
This is only an issue if your bot's code continues to execute for some unbounded amount of time instead of returning from the initial incoming http request.
@willportnoy I'm sending my message through message.SendMessage method, not using PostAsync
Right, it looks like you're using the IConnectorClient to send the message, which will always send the message immediately.
However, the default implementation of IBotToUser will queue one message to allow returning a message inline with the initial http request.
You may also run into issues if the Message you send through the IConnectorClient wasn't initialized with code like this:
https://github.com/Microsoft/BotBuilder/blob/master/CSharp/Library/Dialogs/BotToUser.cs#L70
I'm going to close this issue, but feel free to open a new issue for more discussion.