WFH Tip 19: Did you know that there are two different ways of defining replies in the Zobot?

WFH Tip 19: Did you know that there are two different ways of defining replies in the Zobot?

What are replies?

When the Zobot can handle the visitor on its own, the reply action can be used to provide replies to the visitors' queries. replies accept only a collection(i.e. a list) as the value. The collection can, in turn, have one or more strings or maps. There are two options available when this action is used.
  1. It can be used when there are one or more text replies to be displayed.
  2. In case of multiple maps when display cards such as articles, images, and links are used.
This post will talk about one of the lesser-known, more useful methods of defining replies inside the Zobot

Syntax:
  1. response.put("replies",["Text1","Text2"]);

How can you define replies?

There are two ways of defining replies inside the Zobot.

Example 1:
Defining replies as a collection -"replies" which can be a collection of strings that display only text messages.
  1. replies = Collection();
  2. replies.insert("Here is the list of newly launched cars with their specification");
  3. replies.insert("Astra - January 2020 - ₹ 8- 14 lakhs");
  4. replies.insert("Beta - March 2020 - ₹ 8- 14 lakhs");
  5. response = Map();
  6. response.put("replies", replies);
  7. response.put("action","reply");
Example 2:
A combination of strings and multiple maps - In case the developer wants the bot to display cards like images, videos, links,etc as replies, rather than simple text messages, a collection of reply map can be used.
  1. replies = Collection();
  2. replies.insert({
  3. "text": "Here is the list of newly launched cars with their specification",
  4. "type":"links",
  5. "links" : [{"url":"https://www.astra.com/cars", "text":"View more"}]
  6. });
  7. replies.insert({
  8. "text": "Astra - January 2020 - ₹ 8- 14 lakhs",
  9. "image":"https://www.astra.com/images/vehicles.png"
  10. });
  11. replies.insert({
  12. "text": "Beta - March 2020 - ₹ 8- 14 lakhs",
  13. "image": "https://i.ytimg.com/vi/tZeKlqKAPE4/maxresdefault.jpg"
  14. });
  15. response = Map();
  16. response.put("replies", replies);
  17. response.put("action","reply");
To learn more about connections, start building your own Zobot right away.
We also have Sample Scripts that use connections. 
For more information, check out our Help Documentation.

Related Topics:

Regards,
Michelle