Zoho FSM | Send notifications of new requests

Send notifications of new requests

Use case: Notify the Administrator via SMS and the Call Center Agent via email of new requests. Here, the SMS will be sent via Twilio.
 
Follow the steps below to implement this use case:
Step 1: Create a connection for Twilio
Step 2: Create a custom function
Step 3: Create a workflow rule

Step 1: Create a connection for Twilio

To use the Twilio API for sending SMS via the invokeURL task, you need to create a connection for Twilio. To do so:
  1. Navigate to Setup > Developer Space > Connections and click Create Connection.



  2. Under the Default Services tab, select Twilio.



  3. Enter the Connection Name as Twilio and click Create And Connect.
    The Connection Link Name will be automatically populated. Disable Use Credentials Of Login User. If this is disabled, the connection will utilize the credentials of the connection owner.

  4. Click Connect.



  5. Click Authorize in the Authorization page.



  6. Enter the Account SID and Auth Token and click Authorize.


In the custom function, where the Twilio API is used via the invokeURL task, use this Connection Link Name.

Step 2: Create a custom function

Create a custom function in Zoho FSM to notify the Administrator via SMS and the Call Center Agent via email of new requests as they come in. Here, the SMS service provider used is Twilio.
  1. Navigate to Setup > Automation > Functions and click Create Function.



  2. Enter the following details and click Save:
    1. Function Name: NotifyUserAboutNewRequest
    2. Module: Requests
    3. In the Deluge Script Editor, enter the following script:


      /*----------------------------------
      Fetch all Customer Service Agent email
      ----------------------------------*/
      userEmail = "";
      userMobile = "";
      UserRespList = zoho.fsm.getRecords("users").get("users").toList();
      for each  UserResp in UserRespList
      {
      UserRespMap = UserResp.toMap();
      if(UserRespMap.get("client_profile") == "Customer Service Agent")
      {
      userEmailTemp = UserRespMap.get("email");
      userEmail = userEmail + "," + userEmailTemp;
      }
      if(UserRespMap.get("client_profile") == "Administrator")
      {
      userMobile = UserRespMap.get("mobile");
      }
      }
      if(userEmail != "")
      {
      userEmail = userEmail.subString(1,userEmail.length());
      }
      /*----------------------------------
      Fetch Request Detail
      ----------------------------------*/
      requestId = request.get("id");
      requestResp = zoho.fsm.getRecordById("Requests",requestId);
      requestData = requestResp.get("data").toMap();
      Name = requestData.get("Summary");
      id = requestData.get("id");
      Phone = requestData.get("Phone");
      Email = requestData.get("Email");
      Priority = requestData.get("Priority");
      Contact = requestData.get("Contact").toMap().get("name");
      /*----------------------------------
      construct message
      ----------------------------------*/
      message = "Dear Customer Service Agents,<br><br> A new request has been added to FSM. Details are as follows: <br><br> Request Summary - " + Name + ", <br>Priority - " + Priority + ", <br>Customer name - " + Contact + ",<br> Customer Email - " + Email + ",<br> Customer Phone - " + Phone + ",<br> FSM Link - https://fsm.zoho.com/home#/tab/Requests/" + id + "<br><br>Kindly check the request and do the needful. <br><br>Thanks & Regard,<br>Admin";
      /*----------------------------------
      Send Mail
      ----------------------------------*/
      sendmail
      [
      from :zoho.adminuserid
      to :userEmail
      subject :"New Request received in FSM"
      message :message
      ]
      /*----------------------------------
      Send SMS
      ----------------------------------*/
      bodymap = Map();
      bodymap.put("To",userMobile);
      bodymap.put("From","+15139958354");
      bodymap.put("Body",message);
       
      //Replace {AccountSid} with actual value
      sms_response = invokeurl
      [
      type :POST
      parameters:bodymap
      connection:"twilio"
      ];
      info sms_response;
Replace {AccountSid} with the actual value. Refer Twilio's API documentation for details.
 

Step 3: Create a workflow rule

Create a workflow rule in Zoho FSM to notify the Administrator via SMS and the Call Center Agent via email of new requests.
  1. Navigate to Setup > Automation > Workflow Rules and click Create Workflow.
  2. Enter the following details, then click Next :
    1. Module: Requests
    2. Rule Name: Notify User about New Request
    3. Description: Notify the Administrator via SMS and the Call Center Agent via email of new requests



  3. Select the rule trigger as Created and click Next.
  4. Select the rule criteria as To all Requests. Click Next.



  5. Click +Action and select Function.



  6. Select Existing Functions and click Next.



  7. Select the function created in the previous step.



  8. Click Save.

Testing the use case

Create a Request. The Administrator will receive a SMS and the Call Center Agent will receive an email notification.
 
Note:
Ensure that the mobile number of the Administrators is formatted with a + and country code.