Created
June 13, 2020 08:56
-
-
Save jeznag/09ebdb1a9a6fb82e2d0a45e512b12389 to your computer and use it in GitHub Desktop.
Code for Zoho Flow to invoke Twilio SMS function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
info lead_type; | |
lead_id = lead_id_str.toLong(); | |
lead_data = zoho.crm.getRecordById("Leads",lead_id); | |
// From: the Twilio number you will use to send the message | |
from_number = "+61429357123"; | |
// To: the number to which the SMS should be sent | |
to_number = lead_data.get("Phone"); | |
// The To Name will appear in the SMS Message title, e.g. "Sent to John Smith on 23-Mar-2020" | |
to_name = lead_data.get("First_Name") + " " + lead_data.get("Last_Name"); | |
// get the template ID from the URL of a template record | |
// e.g. I got this template ID from https://crm.zoho.com/crm/org25224183/tab/CustomModule7/803228000008928033/edit | |
template_id = 803228000008928033; | |
payload = {"params":{"arguments":{"From":from_number,"To":to_number,"To_Name":to_name,"Entity_Type":"Lead","Entity_Id":lead_id,"template_id":template_id}}}; | |
sms_response = twiliosmsextension0.twiliosms(payload); | |
return sms_response; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void send_sms() | |
{ | |
url = "https://www.zohoapis.com/crm/v2/functions/test_twilio_send/actions/execute?auth_type=apikey&zapikey=..."; | |
param = Map(); | |
param.put("lead_id_str","803228000007670075"); | |
param.put("lead_type","Red Hot Lead"); | |
files = list(); | |
for each key in param.keys() | |
{ | |
stringpart = Map(); | |
stringpart.put("stringPart","true"); | |
stringpart.put("content","" + param.get(key)); | |
stringpart.put("paramName",key); | |
files.add(stringpart); | |
} | |
response = invokeurl | |
[ | |
url :url | |
type :POST | |
headers:{"Content-Type":"multipart/form-data"} | |
files:files | |
]; | |
info response; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment