Guest User

Untitled

a guest
Jan 20th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. import { IPromptChoiceResult, Library, ListStyle, Prompts } from "botbuilder";
  2. import { format } from "util";
  3. import strings from "../../strings";
  4. import { setColour } from "../data/userData";
  5.  
  6. const lib = new Library("colour");
  7.  
  8. lib
  9. .dialog("setFavourite", [
  10. session => {
  11. session.sendTyping();
  12.  
  13. Prompts.choice(
  14. session,
  15. strings.colour.setFavourite.prompt,
  16. strings.colour.setFavourite.colours,
  17. {
  18. listStyle: ListStyle.auto,
  19. retryPrompt: strings.colour.setFavourite.retryPrompt
  20. }
  21. );
  22. },
  23. async (session, result: IPromptChoiceResult) => {
  24. // Removing undefined as choice prompt will ensure value.
  25. const chosenColor = result.response!.entity;
  26.  
  27. setColour(session, chosenColor);
  28.  
  29. const message = format(
  30. strings.colour.setFavourite.selection,
  31. chosenColor
  32. );
  33.  
  34. session.endDialog(message);
  35. }
  36. ])
  37. .triggerAction({
  38. // LUIS intent
  39. matches: "colour:setFavourite"
  40. });
  41.  
  42. export default lib;
Add Comment
Please, Sign In to add comment