How to access and integrate a Flow?

The ‘Use’ tab within ZBrain Flow enables you to integrate your carefully crafted Flows into your actual product. This enables you to leverage the power of AI directly within your application.

Here's a breakdown of the key elements within the ‘Use’ tab:

Flow URL

In the ‘Use’ tab of Flow, you can find the unique URL for your Flow, which serves as the endpoint you need to POST in order to use the Flow.

API key (Authorization Token)

  • You must include your API key in the authorization header using the bearer scheme.

  • You can obtain your API key from Settings -> My Account

Sample Curl, Javascript, and Python

Use the below code snippets written in Curl, Javascript, and Python, respectively, to trigger your Flow using the Flow URL and your API key.

Sample Curl

curl --location '<Flow URL>' \ # Replace '<Flow URL>' with the actual URL of your Flow.
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer 'API_KEY'' \
--data '{}

Sample Javascript

const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Bearer 'API_KEY'");

const raw = JSON.stringify({});

const requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
redirect: "follow"
};

fetch('<Flow URL>', requestOptions) // Replace '<Flow URL>' with the actual URL of your Flow.
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));

Sample Python

import requests
import json
url = '<Flow URL>'  # Replace '<Flow URL>' with the actual URL of your Flow.

payload = json.dumps({})
headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer 'API_KEY''
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Note: In all code samples, replace '<Flow URL>' with the actual URL of your Flow and 'API_KEY' with your actual API key.

Last updated