Zobot Tip 2: Personalize every conversation by storing and re-using visitor data

Zobot Tip 2: Personalize every conversation by storing and re-using visitor data

Each time a visitor enters your website is counted as a visit. A visitor session includes all of a visitor's activities ranging from the first page view to the last activity that he or she does before exiting the website.So, how do you keep track of all the activities of this visitor and the details that he shares during the session? The visitorsession API is used to store values temporarily during a chat conversation with the website visitor.

For example, if you want to perform an action like triggering a message to the visitor based on the time he had logged in to the website, you can set/get the visitor's logged in time during your conversation with the visitor using the visitorsession API. 

Let me elaborate on this with another example.

Say, you are the owner of an online clothing store. A visitor lands your website and starts looking for clothes. The bot sends him a welcome message and offers to guide him through the products available on the site. It asks for his size so that it can display relevant options. When he enters his size, the list of clothes that match the given size are displayed. This data can be stored during the course of the conversation using the visitorsession API and used during a later part of the conversation so that the visitor does not have to enter the same data time and again.

   

visitorsession APIs:
  1. zoho.salesiq.visitorsession.set($screenname,{"name":"Patricia Boyle"});
  2. zoho.salesiq.visitorsession.get($screenname,"name");
Sample Code:
  1. msg = message.get("text");

  2. response = Map();


  3. //Get values

  4. sessionvalue = zoho.salesiq.visitorsession.get("zylkerinc","size");

  5. data = sessionvalue.get("data");

  6. size = data.get("size");

  7. response.put("action","reply");

  8. response.put("action","reply");

  9. response.put("replies", {"We have found the following for you and you'll love it for sure"});


  10. //Set values

  11. if(context_id.equals("shopping"))

  12. {

  13. size = answers.get("size").get("text");

  14. zoho.salesiq.visitorsession.set("screenname",{"size": size});

  15. response.put("action","reply");

  16. response.put("replies", {"Please select a category"});

  17. response.put("suggestions", {"Winter wear","Summer wear"});

  18. return response;

  19. }


Note:
The values stored inside the visitor session API will be available only till the end of the ongoing chat.

Happy Zoboting!

Regards,
Michelle.