await client.Messages.SendMessageAsync(reply) in OAuthCallback doesn't actually send message
await client.Messages.SendMessageAsync(reply); doesn't seem to send message to the user saying they are logged in. I'm running on the bot emulator.
From OAuthCallbackController.cs
`// Resume the conversation to SimpleFacebookAuthDialog
var reply = await Conversation.ResumeAsync(Constants.botId, userId, conversationId, msg, connectorType: connectorType);
// Remove the pending message because login flow is complete
IBotData dataBag = new JObjectBotData(reply);
PendingMessage pending;
if (dataBag.PerUserInConversationData.TryGetValue("pendingMessage", out pending))
{
dataBag.PerUserInConversationData.RemoveValue("pendingMessage");
var pendingMessage = pending.GetMessage();
reply.To = pendingMessage.From;
reply.From = pendingMessage.To;
// Send the login success asynchronously to user
var client = Conversation.ResumeContainer.Resolve<IConnectorClient>(TypedParameter.From(connectorType));
await client.Messages.SendMessageAsync(reply);
return Request.CreateResponse("You are now logged in! Continue talking to the bot.");
}`
@msft-shahins how do you direct the IConnectorClient to point to the bot emulator when resuming from an oauth callback?
if the bot is running on localhost (your oauth callback url is configured to be forwarded to the localhost), everything should work automatically; since pending message will have the channel id of the emulator. The emulator will not receive the proactive messages from bot, if your bot is not running on the localhost (emulator is listening for incoming messages on localhost:9000).
weird it works when I publish the bot but not on the localhost emulator
It seems this is still not working (using the ResumptionCookie approach)
if you are driving the bot using the emulator you should make sure that your bot is running on localhost and your oauth callback is set to localhost. That is the only way to get the proactive messages from your bot on emulator. I recommend debugging the bot and see if the SendMessageAsync(...) call in OAuthCallbackController completes successfully.
Thanks @msft-shahins Yes, it's not working in Localhost and also it's not working when hosted in Azure.
When running in localhost my oauth callback is set to localhost too.
@ejadib can you debug the bot and make sure that IConnectorClient.BaseUri is set to http://localhost:9000/. Port 9000 is the port that emulator is listening on.
@msft-shahins my bad. It's working as expected in both localhost and in Azure. I got confused because the message that was being posted was exactly equals to the message from next dialog in my continuation chain.
a while ago everything was working fine on azure but now it is not throwing the message like it does in localhost. when I test it in localhost it correctly returns the message but this doesn't happen in azure.
is there some sort of breaking change that was introduced or is there some sort of caching going on?
a month ago I didn't have any sort of problem like this and all of sudden since the recent release of 1.1 and 1.2 I find either my bot breaks or there's inconsistencies between my azure and localhost emulator behavior.