Consuming Webhooks in Martini
Martini provides flexibility for integrating webhooks, allowing you to choose from three main methods based on your use case. These options include using a webhook trigger node within a workflow, exposing a service as an ad-hoc REST URL, or creating a REST API dedicated to handling webhook events.
1. Using a Webhook Trigger Node in a Workflow
The webhook trigger node is ideal for scenarios where you want to initiate workflows in response to incoming webhook events. This approach provides seamless integration with workflows, allowing you to define custom processing steps within Martini.
Steps to Use the Webhook Trigger Node
- Open the Workflow Designer: In Martini, navigate to the Workflow Designer where you can create or edit workflows.
- Add the Webhook Trigger Node: Drag the "Webhook Trigger" node into the workflow.
- Configure the Node:
- Specify the endpoint URL to which the webhook provider will send requests.
- Set up any required headers or parameters expected in the incoming webhook payload.
- Define Workflow Logic: Design the workflow steps to process the incoming data as needed.
- Activate the Workflow: Once configured, activate the workflow by triggering a webhook request to the URL of the workflow.
This method ensures that each incoming webhook request triggers the defined workflow, allowing you to process, store, or transform the data directly within Martini.
2. Exposing a Service as an Ad-Hoc REST URL
Exposing a service as an ad-hoc REST URL is a straightforward way to consume webhooks without creating a dedicated REST API. This approach allows you to handle webhook requests by mapping them to a specific service in Martini.
Steps to Expose a Service as an Ad-Hoc REST URL
- Create the Service: Create a service in Martini that includes the logic for processing incoming webhook requests.
-
Expose the Service:
- Click the Service Configuration in the service editor toolbar.
- Select the "REST" tab.
- Specify the HTTP method (e.g., POST) and URL path for the webhook endpoint.
-
Configure the Body Parameter: Set up the service to handle the parameters sent by the webhook provider.
- Save and Deploy: Once the service is configured, save and deploy it, making it accessible at the specified URL.
Using an ad-hoc REST URL for a service allows you to test and use a specific service for webhook consumption without needing a full REST API structure.
3. Creating a REST API
Creating a REST API is a suitable option when you require a structured and scalable approach to consume webhooks. This method allows you to define multiple endpoints and operations within a dedicated API.
Steps to Create a REST API for Webhook Consumption
- Define a New REST API: In Martini, create a new REST API.
- Set Up an Endpoint for the Webhook:
- Add an endpoint specifically for the webhook, configuring the URL path and HTTP method (e.g., POST).
- Define the expected payload structure and any required headers.
- Map to Service Logic: Link the endpoint to a service in Martini that processes the webhook data.
- Publish the API: Once the API and endpoints are configured, publish the API to make it accessible for webhook integrations.
Creating a REST API provides a robust structure for webhook consumption and can easily accommodate additional endpoints if the webhook provider requires multiple triggers or actions.