langflow-ai / langflow

⛓️ Langflow is a visual framework for building multi-agent and RAG applications. It's open-source, Python-powered, fully customizable, model and vector store agnostic.

Home Page:http://www.langflow.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

If I want to execute a flow using a webhook in the form of a curl command, how should I do it?

YamonBot opened this issue · comments

If I want to execute a flow using a webhook in the form of a curl command, how should I do it?

To execute a flow using a webhook in the form of a curl command, you can use the following command:

curl -X 'POST' \
  'http://<your_server>/run/{flow_id}' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'x-api-key: YOUR_API_KEY' \
  -d '{
        "input_value": "Sample input",
        "input_type": "chat",
        "output_type": "chat",
        "tweaks": {}
      }'

This command sends a POST request to the specified server and flow ID, including the necessary headers and JSON payload to execute the flow. If authentication is not required, you can omit the -H 'x-api-key: YOUR_API_KEY' header [1][2][3].

To continue talking to Dosu, mention @dosu.

@dosu

Using the WebhookComponent with Defined Data Field

Given the API endpoint is set up like this:

curl -X POST \
  "https://langflow.yamon.io/api/v1/webhook/8d769a67a" \
  -H 'Content-Type: application/json' \
  -H 'x-api-key: <your api key>' \
  -d '{"any": "data"}'

And I have defined the Data field of the WebhookComponent as follows:

{
  "session_id": "12345",
  "sender_name": "John",
  "input_value": "hello"
}

How should I call the webhook using curl?

To call the webhook using curl with the defined data field, you can use the following command:

curl -X POST \
  "https://langflow.yamon.io/api/v1/webhook/8d769a67a" \
  -H 'Content-Type: application/json' \
  -H 'x-api-key: <your api key>' \
  -d '{
        "session_id": "12345",
        "sender_name": "John",
        "input_value": "hello"
      }'

This command sends a POST request to the specified webhook endpoint, including the necessary headers and JSON payload with the defined data fields. Make sure to replace <your api key> with your actual API key if authentication is required [1][2].

To continue talking to Dosu, mention @dosu.