response = Map();
info answers;
//context handler to create an event in google calendar 
if(context_id.equals("createevent"))
{
	name = answers.get("name").get("text");
	email = answers.get("email").get("text");
	date = answers.get("slot_selected");
	meta = date.get("meta");
	displayslot = date.get("text").toList(" ");
	card_data = meta.get("card_data");
	slot = card_data.get("value").get("slot");
	
	formattedDate = slot.toList("-");
	slot = formattedDate.get(1) + "/" + formattedDate.get(0) + "/" + formattedDate.get(2);
	value = slot.toDateTime();
	selectedSlot = value.getYear().toString() + "-" + value.getMonth().toString() + "-" + value.getDay().toString() + "T" + value.getHour().toString() + ":" + value.getMinutes().toString() + ":" + value.getSeconds().toString();
	//indian time zone has been configured
	timeString = {"start":{"dateTime":selectedSlot,"timeZone":"Asia/Kolkata"},"end":{"dateTime":selectedSlot,"timeZone":"Asia/Kolkata"},'summary':'Call with ' + name + '(' + email + ')'};
	apiresponse = invokeurl
	[
		url :"https://www.googleapis.com/calendar/v3/calendars/primary/events"
		type :POST
		parameters:timeString.toString()
		headers:{'Content-type':'application/json;'}
		connection:"googlecalendar5"
	];
	info apiresponse;
	if(apiresponse.containsKey("status"))
	{
		status = apiresponse.get("status");
		if(status.equalsIgnoreCase("confirmed"))
		{
			confirmation = "Done!! :) Your appointment has been scheduled with our reps on " + displayslot.get(0) + " " + displayslot.get(1) + " " + displayslot.get(2) + " " + displayslot.get(3);
		}
		else
		{
			confirmation = "Sorry! There seems to be an issue. please try again later";
		}
	}
	else
	{
		confirmation = "Sorry! There seems to be an issue. Please try again later";
	}
	response.put("action","end");
	response.put("replies",{confirmation});
}
//context handler to display sorry message and send a mail to business owner
else if(context_id.equals("noslots"))
{
	name = answers.get("name").get("text");
	email = answers.get("email").get("text");
	sendmail
	[
		from :zoho.adminuserid
		to :"bradshawlucas15@gmail.com"
		subject :"Zoho SalesIQ | Demo Session"
		message :"<div>Dear Team,<br></div><div><br></div><div>Customer waiting for a time slot.<br></div><div><br></div><div>Name: " + name + "<br></div><div>Email address: " + email + "<br></div><div><br></div><div>Thanks,<br></div><div>Zylker Webmaster<br></div>"
	]
	response.put("action","end");
	response.put("replies",{"Sorry. There are no time slots available now. We will send you a mail once we get a free slot"});
}
return response;