
Conversations with Bot Template Framework.
In part 2 of our series of articles about the Bot Template Framework, we created a menu in which you need to ask the user to provide feedback about the studio (menu button – “What you think”).
Therefore, in this article, we will consider the so-called “ask” block.
Ask block
This is a block that allows you to get information from the user and then save it to a variable. A distinctive feature of the block is its ability to receive text information that the user can send to the chat. The Ask block remembers the last question and waits for input from the user for the time that is set by the “conversation_cache_time” parameter in the Botman settings, in other words, the ask block uses the Conversation mechanism (you can read about it on the official Botman site).
And so, here is our ask block, which is executed when you click on the “What you think” button.
1 2 3 4 5 6 7 8 9 |
{ "name": "Feedback", "type": "ask", "content": "Please, type your feedback here", "template": "feedback", "result": { "save": "{{feedback}}" } } |
As you can see, we subscribe to the “feedback” keyword, send the message “Please type your feedback here” making it clear that the chatbot is waiting for text input from the user, and then saves the result to a variable under the same name “{{feedback}}” (variable is stored in userStorage).
Obviously, we need to thank the user for their efforts so we will add another text block and the “next” field in the “ask” block.
1 2 3 4 5 |
{ "name": "Feedback End", "type": "text", "content": "Thank you, for your feedback!" } |
Conclusion
Bot Template Framework offers a faster and more elegant solution for creating conversational scripts, in contrast to the Botman’s Conversation mechanism.
In the next article, we will consider in more detail the capabilities of the “ask” block.
The full chatbot script at the end of the third part:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
{ "name": "My Hello World Bot", "blocks": [ { "name": "Menu Block", "type": "menu", "template": "hi;/start", "content": { "text": "Hello there! Welcome to Beedevs chatbot development studio!", "buttons": [ {"feedback": "Tell us what you think"}, {"quote": "Request a quote"}, {"about": "About"} ] } }, { "name": "About Block", "template": "about", "type": "image", "content": { "text": "We are chatbots development studio. Our mission is to shape and deliver modern and easy way of communication between business and its customers by means of messengers and social networks.", "url": "https://beedevs.com/images/ms-icon-310x310.png", "buttons": { "https://beedevs.com": "Website", "articles": "Blog Articles" } } }, { "name": "Articles Block", "type": "carousel", "template": "articles", "content": [ { "title": "Bot Template Framework. First Look.", "url": "https://blog.beedevs.com/wp-content/uploads/2018/10/BTF-1-768x384.jpg", "description": "Make your first steps with Bot Template Framework", "buttons": { "https://blog.beedevs.com/en/bot-template-framework-part-1": "Read Part 1" } }, { "title": "Bot Template Framework. Graphical UI.", "url": "https://blog.beedevs.com/wp-content/uploads/2018/11/BTF-768x384.png", "description": "Dive into graphical components of Bot Template Framework", "buttons": { "https://blog.beedevs.com/en/bot-template-framework-part-2": "Read Part 2" } }, { "title": "Conversations with Bot Template Framework.", "url": "https://blog.beedevs.com/wp-content/uploads/2018/12/BTF-768x384.png", "description": "Learn how to build conversations using Bot Template Framework", "buttons": { "https://blog.beedevs.com/en/bot-template-framework-part-3": "Read Part 3" } } ] }, { "name": "Feedback", "type": "ask", "content": "Please, type your feedback here", "template": "feedback", "result": { "save": "{{feedback}}" }, "next": "Feedback End" }, { "name": "Feedback End", "type": "text", "content": "Thank you, for your feedback!" } ], "drivers": [ { "name": "telegram", "token": "635222000:AAGulXNIfCfG3KYZpSq3LUvnn0000000000" } ] } |