​visitorsession 

The visitorsession API is used to store values temporarily during a chat conversation with the website visitor.

For example, you provide a service that involves scheduling bookings/appointments. You have programmed the Zobot to schedule an appointment for you by obtaining the name and email of the visitor. The zobot also provides the appointment status by getting the visitor's name and email.

A visitor comes to your website and schedules an appointment by giving your name and email. Now, the visitor wants to check the status of appointments. So, the visitor has to provide their name and email again.

This can be eliminated by using visitorsession API. You can make the zobot to get the name and email from the visitor at the beginning, store it temporarily throughout the chat, use it for scheduling, check status, and many other purposes. Learn more about vissitorsession API here.

Note:

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

Syntax to set values:

Copied<response> = zoho.salesiq.visitorsession.set(<portal_name>, <session_data>,<connection>);

Syntax to get values:

Copied<response> = zoho.salesiq.visitorsession.get(<portal_name>, <key>,<connection>);

Sample Script - to store name and email:

Copied// Get name from the visitor's response
visitor_name = answer.get("name").get("text");
visitor_email = answers.get("email").get("text");

// Create a map to hold the data that needs to be stored
session_map = Map();
session_map.put("visitorName",visitor_name);
session_map.put("visitorEmail",visitor_email);
response = zoho.salesiq.visitorsession.set("portal_1", session_map, "salesIqConnection");

// Fetch name and email address of the visitor
vistor_name = zoho.salesiq.visitorsession.get("portal_1", "visitorName", "salesIqConnection").get("data").get("visitorName");
visitor_email = zoho.salesiq.visitorsession.get("portal_1", "visitorEmail", "salesIqConnection").get("data").get("visitorEmail");