For Zoho Services only:


I'm actually part of something bigger at Ascent Business Solutions recognized as the top Zoho Premium Solutions Partner in the United Kingdom.

Ascent Business Solutions offer support for smaller technical fixes and projects for larger developments, such as migrating to a ZohoCRM.  A team rather than a one-man-band is always available to ensure seamless progress and address any concerns. You'll find our competitive support rates with flexible, no-expiration bundles at http://ascentbusiness.co.uk/zoho-support-2.  For larger projects, check our bespoke pricing structure and receive dedicated support from our hands-on project consultants and developers at http://ascentbusiness.co.uk/crm-solutions/zoho-crm-packages-prices.

The team I manage specializes in coding API integrations between Zoho and third-party finance/commerce suites such as Xero, Shopify, WooCommerce, and eBay; to name but a few.  Our passion lies in creating innovative solutions where others have fallen short as well as working with new businesses, new sectors, and new ideas.  Our success is measured by the growth and ROI we deliver for clients, such as transforming a garden shed hobby into a 250k monthly turnover operation or generating a +60% return in just three days after launch through online payments and a streamlined e-commerce solution, replacing a paper-based system.

If you're looking for a partner who can help you drive growth and success, we'd love to work with you.  You can reach out to us on 0121 392 8140 (UK) or info@ascentbusiness.co.uk.  You can also visit our website at http://ascentbusiness.co.uk.

Zoho Deluge: Text (SMS) reminder using Twilio API (LocalSense)

What?
A very quick article to remind me how to send a text message using Twilio API in Zoho Deluge.

Why?
The use-case here is that we want local sense dialing where specific numbers are used both for outbound and inbound but local to the customer and we want to remind our customer that they have an appointment in 1 hour with us.

How?
The code is actually pretty straightforward but you will need to follow these steps to get the credentials:

  1. Login to your Twilio console
  2. On the dashboard, note the ACCOUNT SID and AUTH TOKEN
  3. In the side menu, expand Phone Numbers > Manage > Active numbers
  4. Note the number you want to use (they have friendly numbers but I use the full number in the first column)

Sending a Text/SMS message
copyraw
//
// using the account SID you obtained in the steps above
v_Account_SID = "ABCDEFabcdef0123456789ABCDEFabcdef";
//
// set this to the authtoken value obtained earlier
v_Auth_Token = "1234567890aaaabbbbccccddddeeeeff";
//
// set this to your Twilio number (dialing/texting from)
v_OurTwilioNumber = "+15017122661";
//
// set this to your customer's number (dialing/texting to)
v_CustomerNumber = "+15558675310";
//
// the message we want to send
v_Message = "This is a test text";
//
// build up the endpoint (see https://www.twilio.com/docs/usage/requests-to-twilio#http-methods for latest endpoint)
v_Endpoint = "https://" + v_Account_SID + ":" + v_Auth_Token + "@api.twilio.com/2010-04-01/Accounts/" + v_Account_SID + "/Messages.json";
//
// build up the JSON request
m_Data = Map();
m_Data.put("Body",v_Message);
m_Data.put("From",v_OurTwilioNumber);
m_Data.put("To",v_CustomerNumber);
//
// JSON request
r_TwilioResponse = invokeurl
[
	url :v_Endpoint
	type :POST
	parameters:m_Data
];
//
// display to user/developer the response
return r_TwilioResponse;
  1.  // 
  2.  // using the account SID you obtained in the steps above 
  3.  v_Account_SID = "ABCDEFabcdef0123456789ABCDEFabcdef"
  4.  // 
  5.  // set this to the authtoken value obtained earlier 
  6.  v_Auth_Token = "1234567890aaaabbbbccccddddeeeeff"
  7.  // 
  8.  // set this to your Twilio number (dialing/texting from) 
  9.  v_OurTwilioNumber = "+15017122661"
  10.  // 
  11.  // set this to your customer's number (dialing/texting to) 
  12.  v_CustomerNumber = "+15558675310"
  13.  // 
  14.  // the message we want to send 
  15.  v_Message = "This is a test text"
  16.  // 
  17.  // build up the endpoint (see https://www.twilio.com/docs/usage/requests-to-twilio#http-methods for latest endpoint) 
  18.  v_Endpoint = "https://" + v_Account_SID + ":" + v_Auth_Token + "@api.twilio.com/2010-04-01/Accounts/" + v_Account_SID + "/Messages.json"
  19.  // 
  20.  // build up the JSON request 
  21.  m_Data = Map()
  22.  m_Data.put("Body",v_Message)
  23.  m_Data.put("From",v_OurTwilioNumber)
  24.  m_Data.put("To",v_CustomerNumber)
  25.  // 
  26.  // JSON request 
  27.  r_TwilioResponse = invokeUrl 
  28.  [ 
  29.      url :v_Endpoint 
  30.      type :POST 
  31.      parameters:m_Data 
  32.  ]
  33.  // 
  34.  // display to user/developer the response 
  35.  return r_TwilioResponse; 

Adapting it to trigger off a scheduled workflow of a call/meeting
  1. Login to ZohoCRM > Setup > Automation > Workflow Rules > Create Rule
  2. Module is "Calls"
  3. Rule Name can be whatever you want, I'm calling mine "Calls - Send SMS Reminder 1 Hr Before"
  4. When is "On a Date/Time" based on "Call Start Time" with execution date "On" the date and execution time "1 hour before".
  5. Condition 1: rule is applied to all calls
  6. Action is the function below with the parameter "p_CallID" being the Calls - Call ID value.
copyraw
//
r_CallDetails = zoho.crm.getRecordById("Calls",p_CallID);
//
// using the account SID you obtained in the steps above
v_Account_SID = "ABCDEFabcdef0123456789ABCDEFabcdef";
//
// set this to the authtoken value obtained earlier
v_Auth_Token = "1234567890aaaabbbbccccddddeeeeff";
//
// get lead details
v_Type = "Leads";
if(!isnull(r_CallDetails.get("$se_module")))
{
	v_Type = r_CallDetails.get("$se_module");
}
// set your default twilio number
v_TwilioLocalNumber = "+12345678910";
v_CustomerNumber = "";
v_CustomerFirstName = "";
if(v_Type == "Leads")
{
	if(!isnull(r_CallDetails.get("What_Id")))
	{
		v_LeadID = r_CallDetails.get("What_Id").get("id");
		r_LeadDetails = zoho.crm.getRecordById("Leads",v_LeadID);
		if(!isnull(r_LeadDetails.get("Twilio_Local_Number")))
		{
			v_TwilioLocalNumber = r_LeadDetails.get("Twilio_Local_Number");
		}
		if(!isnull(r_LeadDetails.get("Mobile")))
		{
			v_CustomerNumber = r_LeadDetails.get("Mobile");
		}		
		else if(!isnull(r_LeadDetails.get("Phone")))
		{
			v_CustomerNumber = r_LeadDetails.get("Phone");
		}		
		if(!isnull(r_LeadDetails.get("First_Name")))
		{
			v_CustomerFirstName = r_LeadDetails.get("First_Name");
		}		
	}
}
//
// set this to your Twilio number (dialing/texting from)
v_OurTwilioNumber = v_TwilioLocalNumber;
//
// send reminder if we have the customer's number
if(v_CustomerNumber!="")
{
	//
	// the message we want to send
	v_Message = "Hi "+v_CustomerFirstName+"! This is just to remind you that we will be phoning you in an hour for your initial consultation with <My_Company_Name>. To reschedule, just reply to this message or phone us on " + v_TwilioLocalNumber;
	//
	// build up the endpoint (see https://www.twilio.com/docs/usage/requests-to-twilio#http-methods for latest endpoint)
	v_Endpoint = "https://" + v_Account_SID + ":" + v_Auth_Token + "@api.twilio.com/2010-04-01/Accounts/" + v_Account_SID + "/Messages.json";
	//
	// build up the JSON request
	m_Data = Map();
	m_Data.put("Body",v_Message);
	m_Data.put("From",v_OurTwilioNumber);
	m_Data.put("To",v_CustomerNumber);
	info m_Data;
	//
	// JSON request
	r_TwilioResponse = invokeurl
	[
		url :v_Endpoint
		type :POST
		parameters:m_Data
	];
}
  1.  // 
  2.  r_CallDetails = zoho.crm.getRecordById("Calls",p_CallID)
  3.  // 
  4.  // using the account SID you obtained in the steps above 
  5.  v_Account_SID = "ABCDEFabcdef0123456789ABCDEFabcdef"
  6.  // 
  7.  // set this to the authtoken value obtained earlier 
  8.  v_Auth_Token = "1234567890aaaabbbbccccddddeeeeff"
  9.  // 
  10.  // get lead details 
  11.  v_Type = "Leads"
  12.  if(!isnull(r_CallDetails.get("$se_module"))) 
  13.  { 
  14.      v_Type = r_CallDetails.get("$se_module")
  15.  } 
  16.  // set your default twilio number 
  17.  v_TwilioLocalNumber = "+12345678910"
  18.  v_CustomerNumber = ""
  19.  v_CustomerFirstName = ""
  20.  if(v_Type == "Leads") 
  21.  { 
  22.      if(!isnull(r_CallDetails.get("What_Id"))) 
  23.      { 
  24.          v_LeadID = r_CallDetails.get("What_Id").get("id")
  25.          r_LeadDetails = zoho.crm.getRecordById("Leads",v_LeadID)
  26.          if(!isnull(r_LeadDetails.get("Twilio_Local_Number"))) 
  27.          { 
  28.              v_TwilioLocalNumber = r_LeadDetails.get("Twilio_Local_Number")
  29.          } 
  30.          if(!isnull(r_LeadDetails.get("Mobile"))) 
  31.          { 
  32.              v_CustomerNumber = r_LeadDetails.get("Mobile")
  33.          } 
  34.          else if(!isnull(r_LeadDetails.get("Phone"))) 
  35.          { 
  36.              v_CustomerNumber = r_LeadDetails.get("Phone")
  37.          } 
  38.          if(!isnull(r_LeadDetails.get("First_Name"))) 
  39.          { 
  40.              v_CustomerFirstName = r_LeadDetails.get("First_Name")
  41.          } 
  42.      } 
  43.  } 
  44.  // 
  45.  // set this to your Twilio number (dialing/texting from) 
  46.  v_OurTwilioNumber = v_TwilioLocalNumber; 
  47.  // 
  48.  // send reminder if we have the customer's number 
  49.  if(v_CustomerNumber!="") 
  50.  { 
  51.      // 
  52.      // the message we want to send 
  53.      v_Message = "Hi "+v_CustomerFirstName+"! This is just to remind you that we will be phoning you in an hour for your initial consultation with <My_Company_Name>. To reschedule, just reply to this message or phone us on " + v_TwilioLocalNumber; 
  54.      // 
  55.      // build up the endpoint (see https://www.twilio.com/docs/usage/requests-to-twilio#http-methods for latest endpoint) 
  56.      v_Endpoint = "https://" + v_Account_SID + ":" + v_Auth_Token + "@api.twilio.com/2010-04-01/Accounts/" + v_Account_SID + "/Messages.json"
  57.      // 
  58.      // build up the JSON request 
  59.      m_Data = Map()
  60.      m_Data.put("Body",v_Message)
  61.      m_Data.put("From",v_OurTwilioNumber)
  62.      m_Data.put("To",v_CustomerNumber)
  63.      info m_Data; 
  64.      // 
  65.      // JSON request 
  66.      r_TwilioResponse = invokeUrl 
  67.      [ 
  68.          url :v_Endpoint 
  69.          type :POST 
  70.          parameters:m_Data 
  71.      ]
  72.  } 

Error(s) Encountered
  • The 'To' number XXXXXXXXXX is not a valid phone number - Resolved: Do not url encode from and to phone numbers (also do not url encode the body/message). Number is formatted to E.164 [+] [country code] [subscriber number including area code] and can have a maximum of 15 digits.

Source(s):
Category: Zoho :: Article: 793

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com

Related Articles

Joes Revolver Map

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Ethereum:
Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF
© 2024 Joel Lipman .com. All Rights Reserved.