Bot Message Handler

The Message Handler is invoked when the bot receives a message from the website visitor. The combination of messages we receive from the website visitor will be analyzed and stored in the code(if the context handler is used) already, and the bot will respond to the visitors based on the question they receive from the available answers.

Example: Consider you walk into the cloth store and nobody approaches you. When you cannot find what you're looking for, you will approach a salesperson with your needs and they will ask you what do you need? what type of materials are you're looking for? This is how the message handler exactly works. 

The attributes passed when a message handler is triggered are listed below:

InputsTypeDescription
messageMapDetails of the message in the conversation (Attribute: text)
visitorMapDetails of the website visitor
operationStringDetails of the operations happen during the chat conversation (Attribute: chat, message)
requestMapDetails of the request

Note: 

  • Each script handler/function will have an execution timeout of 90 seconds
  • Each API invocation from handlers using the invoke URL task should not exceed 40 seconds to be completed
  • If there is any issue in the execution or response of one of the handlers, as a fallback bot will forward the chats to the department operators. 

Message Handlers in Zoho SalesIQ - Bot

To embed the message handler script:

  • Navigate to Settings > Bot > Zobot, click Add.
  • Enter the name, choose the platform - SalesIQ Scripts, and then choose the brand. 
  • The Deluge code builder will appear.
  • Then, choose the Message Handler in the drop-down.
  • And then draft the script in the Message handler section, click Save and Publish.

Sample Output:

Sample Code:

Copiedresponse = Map();
if(operation.equals("chat") || operation.equals("message"))
{
	msg = message.get("text");
	//If the visitor select the "Book Therapy"
	if(msg.containsIgnoreCase("Book Therapy"))
	{
		response.put("action","reply");
		response.put("replies",{"Cool, these are the available therapies, please select one."});
		response.put("suggestions",{"Motivational Therapy","Depression Therapy"});
		return response;
	}
	//After selecting "Book therapy", if the visitor select the "Motivational Therapy"
	else if(msg.containsIgnoreCase("Motivational Therapy"))
	{
		response.put("action","context");
		response.put("context_id","motivational_therapy");
		question1 = {"name":"name","replies":{"May I have your name please?"}};
		question2 = {"name":"email","replies":{{"text":"Can you provide your email address?","validate":{"format":"email"}}}};
		question3 = {"name":"number","replies":{{"text":"Can you provide you phone number"}}};
		question4 = {"name":"date","replies":{{"text":"Please select your preferred Date & Time to Schedule bookings for your therapy"}},"input":{"type":"calendar","from":"+1","label":"Book Now","to":"+10","select_label":"Choose a date"}};
		question5 = {"name":"slot","replies":{{"text":"Okay,these are available slots, please select one!"}},"input":{"type":"timeslots","label":"Schedule appoinment","slots":{"09:00","09:00","10:00","10:30","11:00","11:30"}}};
		questions = Collection();
		questions.insert(question1);
		questions.insert(question2);
		questions.insert(question3);
		questions.insert(question4);
		questions.insert(question5);
		response.put("questions",questions);
	}
	//After selecting "Book therapy", if the visitor select the "Motivational Therapy"
	else if(msg.containsIgnoreCase("Depression Therapy"))
	{
		response.put("action","context");
		response.put("context_id","depression_therapy");
		question1 = {"name":"name","replies":{"May I have your name please?"}};
		question2 = {"name":"email","replies":{{"text":"Can you provide your email address?","validate":{"format":"email"}}}};
		question3 = {"name":"number","replies":{{"text":"Can you provide you phone number"}}};
		question4 = {"name":"date","replies":{{"text":"Please select your preferred Date & Time to Schedule bookings for your therapy"}},"input":{"type":"calendar","from":"+1","label":"Book Now","to":"+10","select_label":"Choose a date"}};
		question5 = {"name":"slot","replies":{{"text":"Okay,these are available slots, please select one!"}},"input":{"type":"timeslots","label":"Schedule appoinment","slots":{"09:00","09:00","10:00","10:30","11:00","11:30"}}};
		questions = Collection();
		questions.insert(question1);
		questions.insert(question2);
		questions.insert(question3);
		questions.insert(question4);
		questions.insert(question5);
		response.put("questions",questions);
	}

In this example, when the visitor starts a reactive conversation with the bot or selects book therapy (invoked by trigger handler), the bot asks name, email, phone number, and date and time to schedule a booking (Therapy).