Activity Webhooks
Webhooks provide a powerful mechanism to receive real-time notifications about activity requests in your Turnkey organization. Additionally, you’ll be able to receive all activity requests for both the parent organization and all its child organizations. This functionality can be enabled via the organization feature capabilities of our platform, as detailed in the section on organization features.
This guide is designed to walk you through the process of setting up webhooks, from environment preparation to verification of successful event capturing.
Prerequisites
Before diving into webhook configuration, ensure you have completed the necessary preliminary steps outlined in our Quickstart Guide. This guide will assist you in setting up a new organization and installing the Turnkey CLI. Note: We’ll create a new API Key for testing webhooks below.
Environment Setup
Begin by setting the necessary environment variables:
API Key Generation
Generate an new API key using the Turnkey CLI with the following command:
Ngrok Installation and Setup
Ngrok is a handy tool that allows you to expose your local server to the internet. Follow these steps to set it up:
Download Ngrok from their website.
Follow the provided instructions to install Ngrok and configure your auth token.
Local Server Setup
Open a new terminal window and set up a local server to listen for incoming webhook events:
Ngrok Tunneling
In another terminal, initiate Ngrok to forward HTTP requests to your local server:
Here’s an output of the above command:
Save the ngrok URL as an environment variable:
Verifying Ngrok Setup
To ensure Ngrok is correctly forwarding requests, perform a test using curl:
Example output:
After executing this command, you should see the request appear in the terminal where nc
is running. Terminate the nc
session by pressing CTRL+C and restart it by rerunning the nc
command.
Configuring the Webhook URL
Set your webhook URL using the Turnkey CLI with the following command:
Testing Your Webhook
Assuming the previous request executed successfully it’s time to test out your webhook! In order to verify that your webhook is correctly configured and receiving data, we can simply execute the previous turnkey request command again which creates a new activity request that will be captured by your webhook. Monitor the terminal with nc
running to observe the incoming webhook data.
Conclusion
By following these steps, you should now have a functioning webhook setup that captures all activity requests for your organization and its sub-organizations. If you encounter any issues or have feedback about this feature, reach out on slack!