Skip to content

Connecting Functions to Triggers

Connecting Functions and Templates to Triggers

To interact with functions and templates in Comnoco from an external program you need to create a Trigger that maps to one or more functions in a Function Collection file. Think of Triggers as the entry point to Comnoco, without one you’re not able to interact with anything else you build.

Using your functions

To make functions run from an external program you need to create a Trigger in Comnoco that will serve as your entry point and kick off (trigger) your functions. A Trigger can map to API Functions, Schedule Functions or Webhook Receivers. Triggers cannot map to a Component Function so you will always need at least one other type of function in your file to be able to run a Component Function from a Trigger.

You need to map your “function to run” with a method (GET, HEAD, POST, PUT, PATCH or DELETE). Once the Trigger has been published in your published workspace you can call it to interact with your mapped function.

Map function in trigger

You can see the name of the Logix file and the name of the functions mapped.

Security in Triggers

You must always secure your Triggers by adding at least one method that you choose in the Trigger Authentication Methods slot.

When your triggers and functions run, they must be told what authority they have to run your workspace and only authenticated triggers will be able to run and use your secrets etc.

This authority is provided by telling the trigger that it can run as a Service User. There are three ways to “secure” your triggers and each will link your user to a service user. The three methods are:

  1. API Key - Use this when you want to require an API key to be sent in the request to the trigger in order to allow access. By default it expects the API key to be sent in a header called API-KEY but you can change that in the block’s settings. You will need to select an API key to use from one that you have created in the API Keys section of the Manage Team/Service Users screen.
  2. No Auth (Public) - Use this when you want anyone to be able to access your trigger without providing auth. If you select this method, you will need to choose a service user to run your trigger and functions.
  3. Advanced Auth - Use this when you want to combine methods, validate IP addresses, Validate HMAC signatures, or use check a user is logged into Supabase.

Using your templates

Once you’ve created an email or document template you need to create a function that consumes the template. This is done in a Logix file where you have to assign the content (or value) of the template to a block. Emails and Documents return text value, use the Set Text block to get the template content and bring it into your function. If you assign the value to an output parameter your function will return the value of the template. Then all you need to do to interact with the template from an external program is to map the function that consumes the template to a Trigger and call the trigger. See using your functions.

Get template in a function

Calling Triggers

When you have set up your function and mapped it in a Trigger you have to publish the workspace for the Trigger to become available to call from an external program.

Once the workspace is published your Triggers will be available on the Status screen. Hover over the method badge (GET, POST, PUT, PATCH or DELETE) to view the URL to call the Trigger with.

Get endpoint url