API Name Method URL CreateWebhook POSTRefer to the Zoho Desk API documentation for the header and body parameter specifications of the API.
A webhook needs to be created to receive real-time notifications from Zoho Desk. But before creating the webhook, you need to define a REST API function that will provide the subscription URL parameter required to construct the CreateWebhook API.
Code snippet
crmAPIRequestMap = crmAPIRequest.toMap();request_body = crmAPIRequestMap.get("body");data = Map();leadsource = "";for each item in request_body{payload = item.get("payload");firstname = payload.get("firstName");lastname = payload.get("lastName");type = payload.get("type");email = payload.get("email");title = payload.get("title");leadsource = payload.get("webUrl");if(type == "Prospect"){data.putAll({"First_Name":firstname,"Last_Name":lastname,"Email":email,"Designation":title,"Lead_Source":"Zoho Desk"});resp = zoho.crm.createRecord("Leads",data);}}signalMap = Map();signalMap.put("signal_namespace","desksynccrmsignal__testsignal");signalMap.put("email",data.get("Email"));signalMap.put("subject","New Notification");signalMap.put("message","A new lead from Zoho Desk");actionsList = List();actionMap = Map();actionMap.put("type","link");actionMap.put("display_name","Lead Source");actionMap.put("url",leadsource);actionsList.add(actionMap);signalMap.put("actions",actionsList);//Raising a signalsigResp = zoho.crm.invokeConnector("raisesignal",signalMap);return "";
Now that we have obtained the subscription URL, let's go ahead and create a webhook. We have chosen to create a webhook during the authorization of the connector.
m = {"nameSpace":"xxx.desksynccrmsignal"}; apikeyresp = zoho.crm.invokeConnector("crm.zapikey",m); zapikey = apikeyresp.get("response"); subscription_url = "https://platform.zoho.com/crm/v2/functions/desksynccrmsignal__signalfunction/actions/execute?auth_type=apikey&zapikey=" + zapikey; dynamic_map = Map(); dynamic_map.put("url",subscription_url); resp = zoho.crm.invokeConnector("desksynccrmsignal.deskconnector.createwebhook",dynamic_map); |
Writer is a powerful online word processor, designed for collaborative work.