What is a Context?

A Context is a data definition that is used to collect multiple inputs to perform a single action. 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 that is invoked after collecting all the inputs for a particular context. Here are the various attributes passed from a bot to a context handler. 

InputsTypeDescription
answersMapAnswers to the questions defined in the context
visitorMapDetails of the website visitor
context_idStringID of the context currently used

Channel compatibility

 

Context ID

  • The context_id is a unique identifier for any context that is available in the Context handler of the Zobot. You can use the context action in case you want to use a set of questions in a particular context to invoke/perform an action.
  • context_id accepts only text as the value. The value must be the name of a context handler block
  • For example, if you want to create a lead in Zoho CRM using the name, email and phone number of the visitor, you can specify questions to get these details from the visitor in the same context.

Note:

  • You can use any number of contexts but when you switch from one context to another, answers from the previous context will not be available in the context handler. For example, if you use the context with context_id leaddetails to collect the visitor name, email and phone to create a lead and then switch to the next context with context_id typeofservice​, answers to questions in leaddetails will not be available in the context handler.
  • Context re-using can be done if you want to reuse the answers collected in a context earlier in questions that come later in the same context. For example, if you use the context with context_id leaddetails to collect the visitor name and email and you want to include the name of the visitor in the next question, you can use the same context again with additional questions added to the same context.

 

Use Case:

Copiedresponse = Map();
if(context_id.equals("leaddetails"))
{
	name = answers.get("name").get("text");
	email = answers.get("email").get("text");
	number = answers.get("number").get("text");
	sendmail
	[
		from :zoho.adminuserid
		to :email
		subject :"Welcome to our Store"
		message :"Hi " + name + "<br>Greetings from Zylker Store!<br>We understand you are interested in our upcoming product. We will send you an mail once the products are launched.<br>If you have any quries please contact us at [support@zylkerstore.com]<br><br>Thanks,<br>Zylker Store"
	]
	leadinfo = {"Last_Name":name,"Email":email};
	info zoho.crm.createRecord("Leads",leadinfo,Map(),"crm");
	response.put("action","end");
	response.put("replies",{"Excellent! Thank you for choosing our services. Kindly check your mail. Have a good day"});
}

In this example, the zobot acts as a virtual assistant for website visitors and creates quality leads. Here, the context handler will be invoked once the bot gets a reply from the visitor for the trigger initiated or while the message handler is executed. In this case, context_id leaddetails will create a lead in Zoho CRM.