Add a webhook trigger

Learn how to add a webhook trigger. You need the Administrator and Triggers Manager user role to access these settings. 

To send data using webhooks in MRI OnLocation, you must create a webhook trigger. This will configure what, when, and where information is being sent.

Webhook triggers are created the same way as other triggers but can only be set up for sign in/out events and use a specific webhook action.

Before setting up a webhook trigger you must have added at least one webhook in your webhook URLs. 

Add a trigger

  1. Go to Locations, then select the location from the drop-down list.
  2. Select Triggers.
  3. Click Create a New Trigger.
  4. In the Trigger Details tab, enter the trigger name.
  5. Select Active as the trigger status.
  6. Select the trigger method. For a webhook trigger you must use a sign in or out event.
  7. Click Next.

    Webhooks-trigger-1.png
  8. (Optional) Enter any trigger rules.

    Rules are used to narrow down the trigger event to more specific scenarios. If you do not have any rules, the trigger will activate every time the trigger occurs.
  9. Click Next.
  10. Click Create a New Action
  11. Select Webhook – Triggers a Webhook URL.
  12. Select the webhook you set up in the Webhooks integration.
  13. Configure the options and test your webhook. See below for more details.
  14. Click Save & Close.

    Webhooks-trigger-3.png

Data

There are two types of data packets you can send using webhooks:

  • Full – sends all standard data which is included in the sign in event, e.g. sign in/out time and method, name, organization, etc.
  • Custom – create a custom data packet to send using placeholders. You must format this data so that it will be read correctly by your third-party application inserting your own headers for each value created by the placeholders.

To enter your placeholders in the data packet:

  1. Click View available placeholders.
  2. Select the category of placeholder.
  3. Click Insert next to a placeholder you want inserted in your custom data packet.

To check how your data will send, use the testing process below. Your data packet will be displayed under the Input Data heading.

Testing

Test your webhook by sending an existing event to the webhook URL to get a response.

  1. Choose a record from the dropdown menu. You can select from the last 10 sign in events for the person type chosen in the Trigger Event. All of the data for that event will be displayed under the Input Data.

  2. Click Send Data.

    Webhooks-trigger-3-preview.png

The data will be sent to your selected webhook as a test and the response will be displayed under the Response Data heading.

Part of the response should have the line {"success":true}, which means it has worked. If it has the line {"success":false} it means it has failed and you need to reconfigure your settings.

Advanced settings

In most scenarios, you would send data to your third-party system using webhooks. That system would do all data processing and send a response back to OnLocation.

An example of how you can process the response further is if you wanted to add custom QR/barcodes to your temporary badge pass.

Printing custom QR/barcodes onto a temporary badge pass is very useful when integrating your access control system with OnLocation through webhooks. Enabling you to return a value from the webhook and add it to the badge pass, e.g. a temporary access code allowing access to certain locations by scanning their badge pass.

To print QR/barcodes on your badge passes:

  • You need to have a badge pass template created and active with QR/barcode for your chosen person type.
  • The longer the value the larger the printed code will be. QR codes can be any length but barcodes can only be a maximum of four characters.
  • The response you receive needs to be in JSON format to be processed.

To set up the ability to return custom data to add to your temporary badge pass:

  1. Test your webhook by sending data.
  2. Copy the JSON path you want to print the value of as a QR/barcode, e.g. access_code.
  3. Click Show Advanced below the test data.
  4. Click Create a New Action.
  5. Paste the JSON path with the prefix $.
  6. Click Select an Action > Set barcode/QR value on printed pass.
  7. Click Save & Close.