Guest User

Untitled

a guest
Jan 20th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. public InitialQuestions(string dialogId, IEnumerable<WaterfallStep> steps = null)
  2. : base(dialogId, steps)
  3. {
  4. AddStep(async (stepContext, cancellationToken) =>
  5. {
  6. var cardAttachment = CreateAdaptiveCardAttachment(_cards);
  7. var reply = stepContext.Context.Activity.CreateReply();
  8. reply.Attachments = new List<Attachment>() { cardAttachment };
  9. await stepContext.Context.SendActivityAsync(reply, cancellationToken);
  10.  
  11. // how can i wait for user to click submit before going to next step?
  12. return await stepContext.NextAsync();
  13.  
  14. // return await stepContext.PromptAsync(
  15. // "textPrompt",
  16. // new PromptOptions
  17. // {
  18. // Prompt = MessageFactory.Text(""),
  19. // },
  20. // cancellationToken: cancellationToken);
  21.  
  22. });
  23.  
  24. AddStep(async (stepContext, cancellationToken) =>
  25. {
  26. // next step
  27. });
  28. }
  29.  
  30. private static Attachment CreateAdaptiveCardAttachment(string filePath)
  31. {
  32. var adaptiveCardJson = File.ReadAllText(filePath);
  33. var adaptiveCardAttachment = new Attachment()
  34. {
  35. ContentType = "application/vnd.microsoft.card.adaptive",
  36. Content = JsonConvert.DeserializeObject(adaptiveCardJson),
  37. };
  38. return adaptiveCardAttachment;
  39. }
  40.  
  41. {
  42. "type": "AdaptiveCard",
  43. "body": [
  44. {
  45. "type": "TextBlock",
  46. "text": "What is your Occupation?"
  47. },
  48. {
  49. "type": "Input.Text",
  50. "id": "SimpleVal",
  51. "placeholder": "Occupation"
  52. },
  53. {
  54. "type": "TextBlock",
  55. "text": "Are you married? "
  56. },
  57. {
  58. "type": "Input.ChoiceSet",
  59. "id": "SingleSelectVal",
  60. "value": "true",
  61. "choices": [
  62. {
  63. "title": "Yes",
  64. "value": "true"
  65. },
  66. {
  67. "title": "No",
  68. "value": "false"
  69. }
  70. ],
  71. "style": "expanded"
  72. },
  73. {
  74. "type": "TextBlock",
  75. "text": "When is your birthday?"
  76. },
  77. {
  78. "type": "Input.Date",
  79. "id": "DateVal",
  80. "value": ""
  81. }
  82. ],
  83. "actions": [
  84. {
  85. "type": "Action.Submit",
  86. "title": "Submit",
  87. "data": {
  88. "id": "1234567890"
  89. }
  90. }
  91. ],
  92. "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  93. "version": "1.0"
  94. }
Add Comment
Please, Sign In to add comment