Combining your Gumloop flows with webhook triggers allows you to build APIs visually with no code!

Webhooks

All Gumloop flows can be triggered via your own external app using Webhooks.

To see the code necessary to trigger your flow, navigate to your flow and click the ‘Your Triggers’ on the left side of the pipeline builder.

Select the option ‘Webhook’ and your preffered language.

Alt text

Inputs

Most useful flows require an input in from the user. Many flows require multiple. Inputs are defined using Input nodes and these inputs can be passed in using webhooks as well!

The following example takes in 3 seperate inputs and sends an email. The inputs represent the recipients email, the email subject and the email body.

Alt text

The ‘input_name’ values represent the id of that input field. These input names are used to map the information you send via the webhook to the appropriate nodes.

The inputs are sent in the JSON body in an attribute pipeline_inputs. This attribute is a list containing JSON objects with two key-value pairs, one representing the input_name and one representing the value to be passed in for the input.

The following is an example of how you would populate these 3 expected fields in an api call (cURL request).

curl -X POST \
      https://api.gumloop.com/api/v1/start_pipeline \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer xxxxxxxxxxxx" \
      -d '{
        "user_id": "xxxxxxxxxxxxxx",
        "saved_item_id": "xxxxxxxxxxxxxx",
        "pipeline_inputs": [{"input_name": "recepient_address", "value": "recepient@gmail.com"}, {"input_name": "email_subject", "value": "Example of an Email Subject Line"}, {"input_name": "email_body", "value": "Example of the Text of an Email Body"}]
      }'

Here is the same request in Python using the requests library:

import requests
import json

url = "https://api.gumloop.com/api/v1/start_pipeline"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer xxxxxxxxxxxxx"
}
data = {
    "user_id": "xxxxxxxxxxxxxx",
    "saved_item_id": "xxxxxxxxxxxxxx",
    "pipeline_inputs": [
        {"input_name": "recepient_address", "value": "recepient@gmail.com"},
        {"input_name": "email_subject", "value": "Example of an Email Subject Line"},
        {"input_name": "email_body", "value": "Example of the Text of an Email Body"}
    ]
}

response = requests.post(url, headers=headers, data=json.dumps(data))

And here is the same request in JavaScript using the fetch API:

const url = 'https://api.gumloop.com/api/v1/start_pipeline';
const headers = {
  'Content-Type': 'application/json',
  Authorization: 'Bearer xxxxxxxxxxxxx',
};
const data = {
  user_id: 'xxxxxxxxxxxxxx',
  saved_item_id: 'xxxxxxxxxxxxxx',
  pipeline_inputs: [
    { input_name: 'recepient_address', value: 'recepient@gmail.com' },
    { input_name: 'email_subject', value: 'Example of an Email Subject Line' },
    { input_name: 'email_body', value: 'Example of the Text of an Email Body' },
  ],
};

fetch(url, {
  method: 'POST',
  headers: headers,
  body: JSON.stringify(data),
})
  .then((response) => response.json())
  .then((data) => console.log(data));

Outputs

When you run a Gumloop pipeline remotely, the POST request to https://api.gumloop.com/api/v1/start_pipeline will return a run_id and a URL that links to the flow run.

Here is an example of the response:

{
  "run_id": B7uiXDngvzFvUWxHRKQFAD,
  "saved_item_id": q3dasHQBidkNeXvAZo6Dby,
  "url": https://www.gumloop.com/pipeline?run_id=B7uiXDngvzFvUWxHRKQFAD&flow_id=q3dasHQBidkNeXvAZo6Dby
}

You can use this run id to poll a separate endpoint to get information about the ongoing run like the status, logs, and outputs when it is completed.

In order to poll, make a GET request to https://api.gumloop.com/api/v1/get_pl_run with run_id as a query parameter.

Here is an example of a GET request with cURL, Python, JavaScript and their outputs:

Request with cURL

curl 'https://api.gumloop.com/api/v1/get_pl_run?run_id=B7uiXDngvzFvUWxHRKQFAD&user_id=your_user_id' \
  -H 'Authorization: Bearer xxxxxxxxxxxxx' \

Request with Python

import requests

url = "https://api.gumloop.com/api/v1/get_pl_run?run_id=B7uiXDngvzFvUWxHRKQFAD&user_id=your_user_id"
headers = {
    "Authorization": "Bearer xxxxxxxxxxxx"
}

response = requests.get(url, headers=headers)
print(response.json())

Request with JavaScript

const url = 'https://api.gumloop.com/api/v1/get_pl_run?run_id=B7uiXDngvzFvUWxHRKQFAD&user_id=your_user_id';
const headers = {
  Authorization: 'Bearer xxxxxxxxxxxxxx',
};

fetch(url, {
  method: 'GET',
  headers: headers,
})
  .then((response) => response.json())
  .then((data) => console.log(data));

Output

{
    "created_ts": "2023-11-19T18:06:31.102786+00:00",
    "finished_ts": null,
    "log": [
        "\u001b[34m__system__: __STARTING__:Read files from GitHub\u001b[0m"
    ],
    "outputs": {},
    "run_id": "B7uiXDngvzFvUWxHRKQFAD",
    "state": "RUNNING",
    "user_id": "your_user_id"
}

The key attributes here are log, state, and outputs.

log: Contains a running log of each node and the activities within it.

state: One of “STARTED”, “RUNNING”, “TERMINATED”, “FAILED” or “DONE”.

outputs: A JSON object with key-value pair where the key is the output name and the value is the output value. This will only be populated when your pipeline reaches a “DONE” state and you have named output nodes in your pipeline.