This guide will talk you through creating a more elaborate dialog when compared to the dialog that’s built in the “Getting Started With Dialogs” page.
In this guide you’ll be building out an order status dialog that:
- Asks the end-user for input using the “Capture Input” node type and validates that same input
- Performs an API call to an external API using the “API Callout” node type to retrieve an order based on the input provided by the end-user
- Validates the response of that API call using the “Logical Step” node type
- And returns the end-user the status of their order
- Should the order not be found, we’ll provide the customer with the ability to go back to the start of the dialog using the “Go To” node type, or to wrap up the dialog.
As stated in the “introduction to Dialogs” page, a dialog is a collection of dialog nodes connected to provide an end-to-end conversational experience.
In this guide we’ll be using all dialog node types to realize our use case:
- Recognition
- Capture Input
- API Callout
- Logical Step
- Output
- Go To
How to Retrieve Order Status Using Dialogs
1. Navigate to https://cms.digitalcx.com
2. Click this button to create an End-To-End integrated Dialog.
3. Click this field and assign an appropriate name to your new dialog.
4. Don't forget to add a corresponding description of your dialog and click on "Create".
5. In this dialog we'll start with creating a recognition node.
6. After adding the recognition node click on "Edit Output" to edit the output of this node.
7. Click here to start typing.
8. Click on "Add answer" once you have finished inputting your text.
9. Click here or the "X" button to exit to the dialog overview.
10. Next, we'll incorporate a capture input node.
11. Click the "Add recognition..." field to add recognition.
12. In this dialog we want to make it possible to retrieve an order status. In this case I'll fill: "I want to retrieve my order status" for the recognition.
13. Click this button to add your recognition for this node.
14. Click here to activate the quick reply.
15. Now go back to your capture input node and click on "Edit Output".
16. Begin typing by clicking here. Whatever you enter will be displayed when the designated recognition or selected dialog option is triggered. In this case I want to capture the email of the customer.
17. Click "Add answer"
18. Click here or the "X" button to exit to the dialog overview.
19. Click on "Dialog variables" to create a new dialog variable.
20. Click the "Variable name..." field.
21. Type "email"
22. Click this button.
23. Click here to close the window.
24. Go back to your capture node and select the dialog variable which you have created in the previous step. This will capture the input of the user into this variable.
25. Click here to select your variable.
26. Click "Quick replies OR regex validation"
Allow quick replies or validate user input using regular expression" if you want to execute a check on the input of the user. This can be done on quick replies or by Regex validation.
27. Click the "Insert expression..." field to insert your regular expression.
28. At "Max retries" you can define a limit on the retries if the validation doesn't pass.
29. Click this field to fill in an error message.
30. In this case I'll type: "This is not a valid email".
31. Click this field to fill in a default value, which can be used at your logic step for e.g.
32. Now I add another "Capture Input" node because I want to retrieve the order number.
33. Click "Edit Output"
34. Begin typing by clicking here. Whatever you enter will be displayed when the designated recognition or selected dialog option is triggered. In this case I want to capture the order number of the customer.
35. Click "Add answer"
36. Click here or the "X" button to exit to the dialog overview.
37. Click "Dialog variables"
38. Click the "Variable name..." field and in this case I'll add a variable where I can save the order number into.
39. Click here to add your dialog variable.
40. Click here.
41. Click here to add the previously created variable where the input needs to be stored into.
42. Click here.
43. In the next step I want to do an "API Callout".
44. Click the "Enter URL... (required)" field to fill in your endpoint.
45. Click "Success Handler"
46. Click "Dialog variables" and create a new dialog variable. In this case a variable where we can save the order status into.
47. Click the "Variable name..." field.
48. Type "orderstatus"
49. Click here to add your dialog variable.
50. Click here.
51. Click here to close the window.
52. Click "Store Response"
53. Click the "Select property... (required)" field and select a property from the response using JMESPath.
54. Click here to select a variable where to save the order status into.
55. Click here.
56. Click "orderstatus"
57. Click "Logical Step"
58. Click "Output"
59. Click "Add condition"
60. Click here to select your variable where you want to make the logic for.
61. In this case the I'll use the dialog variable "orderstatus".
62. Click on condition and define your requirements. In this case: "Not Empty".
63. Click "Edit Output"
64. Click here.
65. Click here to add your dialog variable to the output of this node.
66. Click here.
67. Click "Add answer"
68. Click here or the "X" button to exit to the dialog overview.
69. Now add another "Output" node for when there is no order found.
70. Click "Edit Output"
71. Click "Edit"
72. Click here.
73. Click "Update"
74. Click here.
75. Click on condition and define your requirements. In this case: "Empty".
76. Click here.
77. Click here and select the dialog variable where the logic check needs to be done on.
78. Click "orderstatus"
79. Click "Empty"
80. Click "Go To" and create a new node.
81. Click "Recognition"
82. Click "Set as fallback". What this will do is that if the logic doesn't pass the go to node will function as a fallback in this scenario.
83. Click "Save"
84. Go to your first node and click on: "Test from here" to test your dialog.
85. Click the "Type your question here" field.
86. Click "I want to retrieve my order status" and proceed testing your dialog.