One of Zoho SalesIQ's huge milestones has been the Zobot that was designed to better website visitor interaction, to take over the place of the stereotypical bots and to become the do-gooder when all your operators are busy. This section will majorly focus on providing customers from different business streams with custom bot scripts that they can use for their websites. The post will throw light on a bot that was scripted on Deluge.
What integrations have been accommodated in this bot?
- Google Calendar- to hold scheduled call dates
- Zoho CRM- to record visitor details
The Scenario:
We need a bot that queries visitors about what they need help with, schedules calls and automatically records these on the Google Calendar and also updates visitor details to Zoho CRM at the end of every conversation.
To fulfil this, the following actions have to be performed:
- Configure options for the three different actions specified
- Create connections with Google Calendar and Zoho CRM
- Associate functions to perform these actions
Handlers used:
The backbone of the Zobot is the Handler. Handlers are pre-defined responses to any specific actions/ messages in the bot. You can use them to customize the functionalities of the Zobot.
Trigger Handler:
This piece of code invokes a welcome message to the visitors from the Zobot, when they land on the website.
Message Handler:
When the visitor responds to the message triggered, the Message Handler is invoked. The combination of messages received from the website visitor will be analysed and stored in the context handler already, and the bot will respond to the visitors based on the questions received from the answers available.
Context Handler:
This handler can be used when visitors engage in conversations with the bot. A context is a data definition for collecting multiple inputs to perform a single action. The conversation is mostly in a question-answer format, and can work in association with the message and trigger handlers i.e., the handlers can return a context instead of a message reply. So, all the inputs defined in the context will be collected and the context handler will be invoked. In that case, the context handler is a piece of SalesIQ script which is invoked after collecting all the inputs for a particular context.
What does this Zobot do?
The aforesaid bot was designed as such; it asks the visitor about what service they want to avail - Enquiry, Support or Schedule a call and does the following in response to the actions chosen.
1. If the visitor chooses Zoho Enquiry or the Support option, it demands a bunch of details like the company size, customer name, email address and contact number.
2. When the email address is acquired, a welcome email is sent to the respective address saying that the visitor has been added to the mailing list.
3. Similarly, when all the required details are acquired, it asks the visitors if they want to schedule calls with representatives and when they agree, it schedules calls.
4. When the schedule a call option is chosen by visitors, it requests visitor details and then brings up a calendar along with preset times and lets them pick a slot according to their convenience. Then, the details about the scheduled call are saved to the integrated Google Calendar connection.
- /* Add event to google calendar */
- _date = value.getYear().toString() + "-" + value.getDay().toString() + "-" + value.getMonth().toString() + "T" + value.getHour().toString() + ":" + value.getMinutes().toString() + ":" + value.getSeconds().toString();
- paramMap={"start":{"dateTime":_date,"timeZone":"Asia/Kolkata"},"end":{"dateTime":_date,"timeZone":"Asia/Kolkata"},'summary':'Call with ' + name + '. Contact Number : ' + phone};
- apiresponse = invokeurl
- [
- url :" https://www.googleapis.com/calendar/v3/calendars/primary/events "
- type :POST parameters:paramMap.toString()
- headers:{'Content-type':'application/json;'}
- connection:"your connection name"
- ];
5. At the end of the action, all visitor details will be updated to the synced Zoho CRM account.
- /* Add data to Zoho CRM */
- crmdata = zoho.crm.searchRecords("Leads","(Email:equals:" + email + ")",0,0,Map(),"your CRM connection name");
- info crmdata;
- if(!crmdata.isEmpty())
- { // update existing
- _crmdata = crmdata.get(0);
- info _crmdata;
- leadid = _crmdata.get("id");
- crmdata = zoho.crm.update("Leads",leadid,{"Last_Name":name},Map(),"your CRM connection name");
- }
- else
- {
- // create new lead
- crmdata = zoho.crm.create("Leads",{"Email":email,"Last_Name":name},Map(),"your CRM connection name");
- }
- leadid = crmdata.get("id");
- info leadid;
- info apiresponse;
- if(apiresponse.containsKey("status"))
- {
- status=apiresponse.get("status");
- if("confirmed".equalsIgnoreCase(status))
- {
- question = {"name":"thanks","replies":{"Thank you.","Your appointment has been scheduled with our Sales rep on " + slot}};
- response.put("questions",{question}); return response;
- } }
- question = {"name":"thanks","replies":{"Sorry, please try later"}};
- response.put("questions",{question}); return response;
- }
Note:
I've used the code snippets specified above in the Context handler of the Zobot.
We've attached the
full script for the bot, do give it a try on your website.
I hope this gave you deeper insights about how our Zobots work.
You can learn how to construct your own Zobots and where to include handlers by heading to our
User Guide
Regards,
Michelle.