Triggering a Signal through a Function

You can trigger a custom signal through a function. You must invoke the webhook of that function, which in turn, triggers the signal.

When should you trigger a signal through a function?

  • The third-party application (in which the event occurs) allows you to only register a webhook URL in their service.

  • The third-party application does not send the data back to the webhook URL in the format that the Signals API accepts.

In both these cases, you need a middle layer (middleware) to

  • Consume the webhook call from the third-party application and

  • Construct your pay load to trigger the signal.

Here, a function can act as a middleware, through which you can provide its webhook URL to get notified of the events in the third-party application. Since most third-party apps support only basic authentication, Zoho allows you to trigger functions with the ZAPI key authentication. Also, you can construct the pay load and trigger the signal through out of the box “integration task” or the invoke URL of the signal.

While creating a signal, follow the below steps to trigger a signal through a function.

  1. Select the function (of the type "Signals") that you want to bind with the signal from the Function drop-down in the Create your Signal pop up.

  2. The system automatically populates the webhook URL of the function in the Webhook API field. You must register this URL in the third-party service. Whenever an event occurs in the third-party service, this webhook triggers the function which will trigger the signal.

  3. Select the view type of the signal from the View signal details through drop-down.

Sample function code to trigger the signal

namespace = "zohodesk_newticketalert";
subject = "New Ticket created #"+ticket_id;
message = "New Ticket with "+ticket_subject+" created in Zoho Desk"+" from " +email;
signalMap = Map();
signalMap.put("signal_namespace",namespace);
signalMap.put("email",email);
signalMap.put("subject",subject);
signalMap.put("message",message);
result = zoho.crm.raiseSignal(signalMap);
 

The above code triggers a signal when a new ticket is created in Zoho Desk.

Here, raiseSignal is a predefined task in functions. When you pass a constructed map to this connection, it triggers the Signal notification. This internally calls the signal notifications POST API.

Note
  • If there are no functions of the type "Signals" under the chosen category, you can create a new function from this dialog box. Click Create New Function in the Function box.

  • Your function must have the code to parse the data received from the third-party service, and trigger the signal.

  • You can have the logic to trigger multiple signals in a single function.