For Zoho Services only:


I'm actually part of a bigger team at Ascent Business Solutions where we have support technicians and project consultants. Support is for smaller technical fixes but this can include developments, reports or integrations; depending on the size of the task. Projects are for more time-consuming developments such as revamps of the Zoho Suite of apps or on-site training. The advantage of a team is that if I am out-of-office for a day or so, there is always someone at Ascent Business Solutions who can deal with any queries/issues you may have.

Our support rates can be found and purchased at http://ascentbusiness.co.uk/zoho-support-2. A support bundle doesn't have an expiry date. So whether we can do what you want within the bundle and a year later need further support, if there are minutes left on the bundle then there is no additional charge.

Our project rates for bigger developments can be found at http://ascentbusiness.co.uk/crm-solutions/zoho-crm-packages-prices and will involve a dedicated project consultant along with developers who will hold your hand through the development process.

If you want help building a solution for one of the Zoho Apps in the Zoho Suite, contact us on 0121 293 8140 (UK) or by email at info@ascentbusiness.co.uk. You can also visit our website at http://ascentbusiness.co.uk.

I regularly build and specialize in 2-way API integrations for Xero, Shopify and eBay.

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: The information on this website is provided without warranty and any content is merely the opinion of the author. Please try to test in development environments prior to adapting them to your production environments. The articles are written in good faith and, at the time of print, are working examples used 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 - Valid till 8 May 2022 3QnhmaBX7LQSRsC9hh6Je9rGQKEGNQNfPb
© 2022 Joel Lipman .com. All Rights Reserved.