Guest User

Untitled

a guest
Apr 27th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. bot.dialog('/end', function (session) {
  2. session.endConversation("End Conversation");
  3. }).triggerAction({ matches: /^(exit)|(quit)/i });
  4.  
  5. session.clearDialogStack()
  6.  
  7. session.reset();
  8. session.endDialog();
  9.  
  10. export interface IResetDataSettings {
  11. resetCommand: RegExp;
  12. }
  13.  
  14. export class ResetMiddleware {
  15. public static data(settings: IResetDataSettings): IMiddlewareMap {
  16. return {
  17. botbuilder: (session, next) => {
  18. if (settings.resetCommand && session.message.text && settings.resetCommand.test(session.message.text)) {
  19. session.userData = {};
  20. session.conversationData = {};
  21. session.privateConversationData = {};
  22. session.endConversation("Your conversation state was reset.");
  23. } else {
  24. next();
  25. }
  26. }
  27. };
  28. }
  29. }
  30.  
  31. this.bot.use(ResetMiddleware.data({ resetCommand: /^reset data$/i }));
  32.  
  33. delete session.userData;
Add Comment
Please, Sign In to add comment