Creator Scripts.
Creator Scripts.
Zoho Trusted Partner in Digital Transformation

Introducing Z-3PO a BOT programmed for guidance

27.04.21 05:35 PM By CreatorScripts

Z-3PO is a BOT programmed for guidance built by the heroic team of Creator Scripts using Zoho Sales IQ. The BOT handles live conversations on our website even when we are not online. It learns from our knowledge library and guides the end-user to the tools and information they need.

Affiliations: Zoho

Location: Saltillo, Coahuila Mexico

Creator: Creator Scripts

Below you can find the entire script we used to built Z-3PO. Feel free to use the script below or reach out if you need help building your own custom CHAT BOT.

Message Handler

response = Map();
msg = message.get("text");
if(operation.equals("chat"))
{
if(!msg.equalsIgnoreCase("I'm new here, just browsing") && !msg.equalsIgnoreCase("I'm an existing customer and need help") && !msg.equalsIgnoreCase("I want a product demo"))
{
response = Map();
response.put("action","reply");
response.put("replies",{"Hello there! 👋 Looking to Leverage Zoho and take your platform to the next level?"});
response.put("suggestions",{"I'm new here, just browsing","I'm an existing customer and need help","I want a product demo"});
return response;
}
}
if(msg.equalsIgnoreCase("I'm new here, just browsing"))
{
response.put("action","context");
response.put("context_id","browsing");
question = {"name":"browsing","replies":{"Awesome. Let’s get you started with Deluge Scripting. Here’s our on demand [YouTube Videos](https://www.creatorscripts.com/youtube-tutorials.html) that you can watch at your own pace."},"suggestions":{"Thanks"}};
response.put("questions",{question});
}
else if(msg.equalsIgnoreCase("I'm an existing customer and need help"))
{
response.put("action","context");
response.put("context_id","help");
question = {"name":"help","replies":{"Welcome back Maverick Entrepreneur! Did you know that you can now add and track your own support tickets in our portal? [Support Portal](https://support.creatorscripts.com/portal/en/home)."},"suggestions":{"Need custom development","Online Courses","Can't find what I'm looking for"}};
response.put("questions",{question});
}
else if(msg.equalsIgnoreCase("I want a product demo"))
{
response.put("action","context");
response.put("context_id","demo");
question = {"name":"time","replies":{"Great! Let’s set up a personalized demo to help you manage social media for all your clients. When would you like to schedule it?"},"input":{"type":"calendar"}};
response.put("questions",{question});
}
else
{
response = Map();
response.put("action","reply");
response.put("replies",{"Is there anything else I can help you with?"});
response.put("suggestions",{"I'm new here, just browsing","I'm an existing customer and need help","I want a product demo"});
return response;
}
return response;

Trigger Handler

response = Map();
response.put("action","reply");
response.put("replies",{"Hello there! 👋 Looking for anything specific?"});
response.put("suggestions",{"I'm new here, just browsing","I'm an existing customer and need help","I want a product demo"});
return response;

Context Handler

response = Map();
response.put("action","context");
response.put("context_id",context_id);
if(context_id.equals("browsing"))
{
browsing = answers.get("browsing").get("text");
if(browsing.equalsIgnoreCase("Thanks"))
{
response.put("action","end");
response.put("replies",{"Have a great day"});
}
else
{
response.put("action","reply");
response.put("replies",{"What else can I help you with?"});
response.put("suggestions",{"I'm new here, just browsing","I'm an existing customer and need help","I want a product demo"});
}
}
else if(context_id.equals("help"))
{
help = answers.get("help").get("text");
if(help.equalsIgnoreCase("Need custom development"))
{
if(!answers.containsKey("elsepart"))
{
question = {"name":"elsepart","replies":{"Sure! Please elaborate on the details of the requirement in the following form [Custom Development](https://www.creatorscripts.com/submit-a-request.html) .","Is there any thing else that I can assist you with?"},"input":{"type":"select","options":{"Yes, I need help","No, Thank you"}}};
response.put("questions",{question});
}
else
{
elsepart = answers.get("elsepart").get("text");
if(elsepart.equalsIgnoreCase("Yes, I need help"))
{
if(!answers.containsKey("email"))
{
question = {"name":"email","replies":{{"text":"Can I have your email address so that we can reach you in case the chat gets disconnected","field_name":"siq_email","validate":{"format":"email","error":{"Enter a valid email"}}}}};
response.put("questions",{question});
}
else
{
email = answers.get("email").get("text");
if(!answers.containsKey("name"))
{
question = {"name":"name","replies":{{"text":"Can I have your name please?","field_name":"siq_name"}}};
response.put("questions",{question});
}
else
{
name = answers.get("name").get("text");
if(!answers.containsKey("phone"))
{
question = {"name":"phone","replies":{{"text":"Can I have your phone number in case we need to reach out to you for further follow up","validate":{"format":"phoneno","error":{"Enter a valid phone number"}},"field_name":"siq_phone"}}};
response.put("questions",{question});
}
else
{
phone = answers.get("phone").get("text");
response.put("action","forward");
response.put("replies",{"Please wait while I forward the chat to agents"});
}
}
}
}
else if(elsepart.equalsIgnoreCase("No, Thank you"))
{
if(!answers.containsKey("anythingelse"))
{
question = {"name":"anythingelse","replies":{"Is there any thing else that I can assist you with?"},"input":{"type":"select","options":{"Yes","No"}}};
response.put("questions",{question});
}
else
{
anythingelse = answers.get("anythingelse").get("text");
if(anythingelse.equalsIgnoreCase("Yes"))
{
response.put("action","reply");
response.put("replies",{"Hello there! 👋 Looking for anything specific?"});
response.put("suggestions",{"I'm new here, just browsing","I'm an existing customer and need help","I want a product demo"});
}
else
{
response.put("action","end");
response.put("replies",{"Bye"});
}
}
}
}
}
else if(help.equalsIgnoreCase("Sales Enquiry"))
{
if(!answers.containsKey("email"))
{
question = {"name":"email","replies":{{"text":"Can I have your email address so that we can reach you in case the chat gets disconnected","field_name":"siq_email","validate":{"format":"email","error":{"Enter a valid email"}}}}};
response.put("questions",{question});
}
else
{
email = answers.get("email").get("text");
if(!answers.containsKey("name"))
{
question = {"name":"name","replies":{{"text":"Can I have your name please?","field_name":"siq_name"}}};
response.put("questions",{question});
}
else
{
name = answers.get("name").get("text");
if(!answers.containsKey("phone"))
{
question = {"name":"phone","replies":{{"text":"Can I have your phone number in case we need to reach out to you for further follow up","validate":{"format":"phoneno","error":{"Enter a valid phone number"}},"field_name":"siq_phone"}}};
response.put("questions",{question});
}
else
{
phone = answers.get("phone").get("text");
response.put("action","forward");
response.put("replies",{"Please wait while I forward the chat to agents"});
}
}
}
}
else if(help.equalsIgnoreCase("Can't find what I'm looking for"))
{
if(!answers.containsKey("email"))
{
question = {"name":"email","replies":{"Uh-oh! Sorry about that.",{"text":"Do you have an email address where we can reach you?","validate":{"format":"email","error":{"Please enter a valid email"}},"field_name":"siq_email"}}};
response.put("questions",{question});
}
else
{
email = answers.get("email").get("text");
if(!answers.containsKey("name"))
{
question = {"name":"name","replies":{{"text":"What's your name?","field_name":"siq_name"}}};
response.put("questions",{question});
}
else
{
// handle failure
name = answers.get("name").get("text");
response.put("action","forward");
response.put("replies",{"Please wait while I transfer your chat to the agents"});
}
}
}
else
{
question = {"name":"help","replies":{"Absolutely! Our most popular courses are right here. [Online Courses](https://www.creatorscripts.com/online-courses.html)"},"suggestions":{"Need custom development","Sales Enquiry","Can't find what I'm looking for"}};
response.put("questions",{question});
}
}
else if(context_id.equals("demo"))
{
time = answers.get("time").get("text");
if(!answers.containsKey("email"))
{
question = {"name":"email","replies":{{"text":"Do you have an email address where we can reach you?","field_name":"siq_email","validate":{"format":"email","error":{"Enter a valid email"}}}}};
response.put("questions",{question});
}
else
{
email = answers.get("email").get("text");
response.put("action","end");
response.put("replies",{"Thanks! One of our developers will reach out to you soon."});
}
}
return response;

CreatorScripts