I've uploaded the AnnotatedSandwich sample to my own Azure app service and successfully added the Slack connector so I can order sandwiches through a Slack channel.. so far so good!
However, after I've completed the dialog once on my channel, the bot doesn't respond in the channel anymore and I can't reset it.
I'm aware that a new conversationId is required to kick start a new dialog, however it appears conversationId is always set to the channel name which means I can only start a new dialog if I start a new channel.
https://github.com/Microsoft/BotBuilder/blob/master/Node/src/bots/SlackBot.ts#L339
private fromSlackMessage(msg: ISlackMessage): IMessage {
331 return {
332 type: msg.type,
333 id: msg.ts,
334 text: msg.text,
335 from: {
336 channelId: 'slack',
337 address: msg.user
338 },
339 channelConversationId: msg.channel,
340 channelData: msg
341 };
342 }
343
Is this by design? Are there other ways to kick start a dialog without creating a new channel (which is a hassle)?
So SlackBot.beginDialog() is always the way to start a new conversation. I'll be honest and say this hasn't been super well tested yet so congrats on being the guinea pig... I mean developer... who gets to test it :) Writing unit tests for the Bot adapters is tricky at best.
The intent I had when I thought though how starting a new dialog on Slack should work is that it should blast over the old dialog.
I'm assuming that what you're talking about is not so much a new dialog started with beginDialog() but a new dialog that's started because you made it through the previous task of ordering a sandwich. What needs to happen there is that you need to pop your way out of the conversation with the user on the current channel. Fortunately if you look at the code for the SlackBot it will be stuck in the previous session for at most 5 minutes passed the last reply from the user. With that said you should be calling session.endDialog() to pop yourself out of the dialog stack as you drill into the task. If you don't mind sharing your code I'm happy to provide guidance on what to do where...
This whole thing makes perfect sense to me but I wrote the code so part of this initial phase is trying to understand where developers are getting hung up so we can either improve the documentation or I can improve the code. If something isn't intuitive please tell me and better yet tell me what you think would have been more intuitive.
Thanks.
Sorry I think I was a little confused and I'm not sure if this has anything to do with the SlackBot. Let me take a step back.
This is how I can reproduce my scenario:
On the last step, as a user - I'm expecting the ability to somehow start/reset a dialog again but the bot will not respond to me again :cry:. On the other hand if I invite it to another slack channel, I'll be able to start a new dialog again :smile:.
I just find the need to create a slack channels to start a new dialog again to be quite cumbersome.
On the other hand, I'm not entirely sure what the slack connector does. I presume it's a REST API that reroutes message from slack to botframework.com which then sends them over to my bot. (btw, is the code for the Slack connector open source?)
Oh I see... You're using C# :) I'll get one of the C# guys to help you out.
We store the dialog state with a key of DialogState in the PerUserInConversationData bot data bag. You could clear this out with the IConnectorClient's IBots API, but I agree this is cumbersome, and we should provide a method to do so.
Another that may work in the short term is to null out Message.BotPerUserInConversationData property in your MessagesController.Post - that will reset the dialog state for that conversation.
Or you can try to make a dialog to handle it. This is my way to work around.
example
this will start a new order if old one is completed.
public async Task MessageReceivedAsync(IDialogContext context, IAwaitable
{
var sandwichForm = new FormDialog
context.Call
}
Just for everyone's info, I ended up adding a hack to reset the DialogState in the controller @willportnoy suggested:
``` c#
public async Task
{
if (message.Type == "Message")
{
// dirty hack for now
if (message.Text.ToLowerInvariant() == "reset")
{
message.BotPerUserInConversationData = null;
}
return await Conversation.SendAsync(message, MakeRootDialog);
}
else
{
return HandleSystemMessage(message);
}
}
```
@StephenTung-CR @tomlm Is there a way to automatically reset when dialog ends. So user doesnt have to type in reset ?
I can't seem to find a way during my short stint at it. I tried to clear it
in the OnCompleteAsync on the formbuilder but something seems to override
it afterwards.
If anyone knows a way, please share it.
-Stephen
On Wed, Apr 13, 2016 at 1:06 AM, dat nguyen [email protected]
wrote:
@StephenTung-CR https://github.com/StephenTung-CR @tomlm
https://github.com/tomlm Is there a way to reset when dialog ends. So
user doesnt have to type in reset ?—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/Microsoft/BotBuilder/issues/61#issuecomment-209009762
@willportnoy Is the PerUserInConversationData bag intented to be used by the dialogs to store data from the user that is sending message? Is there a way to get the users data of an specific conversation? Let's say that you have 2 users participating of the same conversation and each of them is storing data in the PerUserInConversationData in a sub-dialog. Is there a way to get what they stored in the main dialog?
message.BotPerUserInConversationData = null; is missing from the new Bot.Connector. What else could we use, @willportnoy, @StephenTung-CR