0

I've built a flow-based chat bot using Wit.ai and FB Messenger that is finally working; the last thing I need to figure out is what to do when the conversation ends.

My bot walks users through the steps of a simple exercise, which they may choose to come back and do again in the future. Is there a way that I can train my bot to recognise that when a user returns to a conversation later on, they need to start the conversation from the beginning again? At the moment the conversation ends with a 'Bot sends' message and if the user types anything in response it goes haywire.

Currently I'm resetting my heroku server, deleting the conversation in FB Messenger and initiating a new chat to run through the exercise again in testing.

wanstan
  • 15
  • 5

2 Answers2

1

Once you've reached the natural stop point in your conversation. You can delete the context properties you set after making the callback.

delete context.loc;

If you want to start the conversation from the very beginning, you could just delete the session.

Bcf Ant
  • 1,639
  • 1
  • 16
  • 26
  • How would you delete something after the callback? Where would that code go? I'm following along with the messenger.js example inside of node-wit and am struggling with this at the moment. – Jim Factor Sep 22 '16 at 23:36
  • Thanks, unable to work on this for a week or so but I will give it a go and report back. – wanstan Sep 23 '16 at 05:41
0

@Jim Factor - If you are using runAction API like the messenger example then once you reach the logical end in conversation you should delete context, session and do other cleanups (like deleting/saving DB entries etc.) in the .then() part of runAction. In the messenger example this is already shown although most of code is commented out. If you pass a new sessionId in runAction then it’s as good as starting a new conversation, but of course, for this to work properly you should also reset the context variables and do other cleanups as relevant for your app. Hope this helps!

MAJ
  • 36
  • 1