Skip to content

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

  1. Open the Workflow Designer: In Martini, navigate to the Workflow Designer where you can create or edit workflows.
  2. Add the Webhook Trigger Node: Drag the "Webhook Trigger" node into the workflow.
  3. Configure the Node:
  4. Specify the endpoint URL to which the webhook provider will send requests.
  5. Set up any required headers or parameters expected in the incoming webhook payload.
  6. Define Workflow Logic: Design the workflow steps to process the incoming data as needed.
  7. 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

  1. Create the Service: Create a service in Martini that includes the logic for processing incoming webhook requests.
  2. 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.
  3. Configure the Body Parameter: Set up the service to handle the parameters sent by the webhook provider.

  4. 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

  1. Define a New REST API: In Martini, create a new REST API.
  2. Set Up an Endpoint for the Webhook:
  3. Add an endpoint specifically for the webhook, configuring the URL path and HTTP method (e.g., POST).
  4. Define the expected payload structure and any required headers.
  5. Map to Service Logic: Link the endpoint to a service in Martini that processes the webhook data.
  6. 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.