Workflow Automation Set up for RingCentral Messaging - Zoho CRM, Ring Central SMS, Texting Extension

Workflow Automation Set up for RingCentral Messaging - Zoho CRM, Ring Central SMS, Texting Extension

The following is a simple code to add as a custom function for a workflow to trigger an SMS messaging using the RingCentral SMS Extension for Zoho CRM:
(the below script is hard coding the phone and email for the sender you can also tweak the code to always use record owner phone and email - remember they need to be authorized to use the extension also and phone number/email combo must match the RingCentral)

If your extension is Version 25 and above please use this code:

Multi-user workflow

This script uses the email of the owner of the record and looks for the phone number in their profile under the phone field to authenticate and send text from that number. The number must match the RingCentral number.  Replace CONNECTIONNAME with your connection set up for CRM USERS ALL.
1.      This is for the leads module.  

Click EDIT ARGUMENTS - select clientid = lead id

Function Code: 

if(input.clientid != null)

{

lead = zoho.crm.getRecordById("Leads",clientid);

leadowner = lead.get("Owner").get("name");

ownerid = lead.get("Owner").get("id");

owneremail = lead.get("Owner").get("email");

num = ifnull(lead.get("Mobile"),"");

fname = ifnull(lead.get("First_Name"),"");

user_email = owneremail;

response = invokeurl

[

url :"https://crm.zoho.com/crm/v2/users/" + ownerid

type :GET

connection:"CONNECTIONNAME"

];

uservalue = response.get("users").toList();

for each  rec in uservalue

{

phone = ifnull(rec.get("phone"),"");

}

sender = phone;

text = "Hi " + fname + ". This is " + leadowner + " welcome to our company";

//replace with text message

resp = ringcentralmessaging.message({"to":num,"from":sender,"text":text,"user":user_email});

info resp;

}


Remember user email and phone must match the RC authorized login.
In your workflow filter be sure to use IF MOBILE IS NOT EMPTY so you don't fire a text to a lead without a phone number.
Make sure your API names are Mobile for the mobile phone field.  
To check your API Names follow these instructions: https://www.zoho.com/crm/help/api-names.html

How to set up the connection: 



How to set up a workflow:



How to authorize users: