How to use webhooks with Axiom.ai
Using webhooks within your Axiom.ai automations can help you to connect to an unlimited number of third party tools, for example, a database management tool and various other tools that can be chained together to complex a complex process to get you to your endpoint. See our guides for more specific guides.
# Getting started
To get started with triggering a webhook using an automation, you will need the following from the Axiom.ai Chrome extension:
- API key - The API key is found on the dashboard.
- Automation name - Get the name of the automation you wish to trigger.
- Endpoint - The current endpoint is
https://lar.axiom.ai/api/v3/trigger.
The information that you'll need to trigger your automation from a third party service varies, check with the service to determine the steps that you need to take in order to set up outgoing webhooks.
# Triggering a webhook from an Axiom.ai automation
There are two methods of triggering a webhook within your automations. For both methods, you'll need to acquire the following data from the third party you're looking to implement:
- Endpoint: The endpoint that needs to be triggered by your automation.
- Payload: The payload format that is required.
# Low-code
The Trigger webhook step can be used in order to trigger a webhook from your automations. Follow the steps below to get started:
- Add a Trigger webhook step.
- Enter the "Endpoint".
- Enter the "Payload".
Remember, the "Insert data" option can be used to dynamically input data from your automation into your payload, see Passing data between steps for more information.
# JavaScript
Webhooks can be triggered using custom JavaScript. This can be used for more advanced fetches and the use of the data that is returned. This has a few benefits, such as:
- Allowing you to receive additional data, from a database, for example.
- Having more control over headers - for example, authorization headers.
- Being able to parse the response.
- Being able to use the response to automatically retry the call in the event of a rate limit being hit.
To get started, add a Write Javascript step to your automation and use the fetch method. See the example below to get started.
const url = "https://example.com/webhook/";
const apiKey = "xxxxxxxxxx";
const data = {
"key": apiKey,
"data": [[1, 2], [3, 4]]
};
const sendData = async () => {
try {
const response = await fetch(url, {
method: 'POST',
headers: {
'apikey': apiKey,
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(format(data))
});
if (!response.ok) {
console.error("Something went wrong with response", response);
return;
}
const result = await response.json();
console.log(result);
} catch (error) {
console.error("Something went wrong", error);
}
}
Learn more about the fetch function in the Mozilla Using the Fetch API (opens new window) documentation.
Remember, the "Insert data" option can be used to dynamically input data from your automation into your payload, see Passing data between steps for more information.
# Triggering an Axiom.ai automation from a webhook
To get started, we're going to assume that you have already set up outgoing webhooks or API calls from the service that you are looking to send information from to your automation. Once this has been done, follow the steps below:
- Add a Receive data from a webhook step.
- Configure the "Test data" input with the expected payload from the third party application.
Configuring the "Test data" helps to test your automation - clicking "Run" on your automation will make use of the test data and can help debug your automation without needing additional webhook calls.
Note, triggering automations from webhooks is only available in specific plans with the 'webhooks' feature.
# Testing your workflow
To test your automation, click "Run". Once done, check the third party tool to confirm if the webhook has been received. Review the builder and your run reports within the extension to determine if there were any issues.
To test sending a webhook to your automation, trigger the webhook from the third party tool that you are implementing. Alternatively, click "Run" to run your automation with the test data in place.
Additionally, the resources below may be helpful in debugging your automation:
# Wrapping up
Triggering webhooks from your automations, or triggering your automations from a webhook call, can allow you to expand the functionality of your automations to give you endless possibilities. Our personal favourite here is our Supabase guide which uses this method to interact with Supabase and allows for the reading and writing of data from your tables. We would love to hear what you do with this option, feel free to post it in our Reddit community (opens new window).
Can't get an API call to work? Ask an expert in our Reddit community (opens new window).