Skip to content

Commit 3f50ee8

Browse files
MQ37TC-MOjirispilka
authored
feat: langflow ai integration docs (#1425)
Add Langflow AI integration docs --------- Co-authored-by: Michał Olender <[email protected]> Co-authored-by: Jiří Spilka <[email protected]>
1 parent b12117d commit 3f50ee8

15 files changed

+133
-0
lines changed

.github/styles/config/vocabularies/Docs/accept.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ preconfigured
9292
asyncio
9393
parallelization
9494
IMDb
95+
96+
97+
Langflow
98+
9599
iPhone
96100
iPhones
97101
iPad
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
---
2+
title: Langflow integration
3+
sidebar_label: Langflow
4+
description: Learn how to integrate Apify with Langflow low-code tool to build powerful AI agents and workflows that can use any API, model, or database.
5+
sidebar_position: 1
6+
slug: /integrations/langflow
7+
---
8+
9+
**Learn how to integrate Apify with Langflow to run complex AI agent workflows.**
10+
11+
---
12+
13+
## What is Langflow
14+
15+
[Langflow](https://langflow.org/) is a low-code, visual tool that enables developers to build powerful AI agents and workflows that can use any API, models, or databases.
16+
17+
:::note Explore Langflow
18+
19+
For more information on Langflow, visit its [documentation](https://docs.langflow.org/).
20+
21+
:::
22+
23+
## How to use Apify with Langflow
24+
25+
This guide will demonstrate two different ways to use Apify Actors with Langflow:
26+
27+
- **Calling Apify Actors in Langflow**: We will use the [RAG Web Browser](https://apify.com/apify/rag-web-browser) Actor to search Google for a query and extract the search results.
28+
- **Building a flow to search for a company's social media profiles**: We will use the [Google Search Results Scraper](https://apify.com/apify/google-search-scraper) Actor to search the web for social media profiles of a given company. Then, we will use the [TikTok Data Extractor](https://apify.com/clockworks/free-tiktok-scraper) Actor to extract data from the TikTok profiles.
29+
30+
### Prerequisites
31+
32+
- **Apify API token**: To use Apify Actors in Langflow, you need an Apify API token. If you don't have one, you can learn how to obtain it in the [Apify documentation](https://docs.apify.com/platform/integrations/api).
33+
34+
- **OpenAI API key**: In order to work with agents in Langflow, you need an OpenAI API key. If you don't have one, you can get it from the [OpenAI platform](https://platform.openai.com/account/api-keys).
35+
36+
#### Langflow
37+
38+
:::note Cloud vs local setup
39+
40+
Langflow can either be installed locally or used in the cloud. The cloud version is available on the [Langflow](http://langflow.org/) website. If you are using the cloud version, you can skip the installation step, and go straight to [Creating a new flow](#creating-a-new-flow)
41+
42+
:::
43+
44+
First, we need to install the Langflow platform using python package and project manager [uv](https://docs.astral.sh/uv/):
45+
46+
```bash
47+
uv pip install langflow
48+
```
49+
50+
After successfully installing Langflow, we can start the platform:
51+
52+
```bash
53+
uv run langflow run
54+
```
55+
56+
When the platform is started, open the [Langflow UI](http://127.0.0.1:7860) in your browser.
57+
58+
> Other installation methods can be found in the [Langflow documentation](https://docs.langflow.org/get-started-installation).
59+
60+
### Creating a new flow
61+
62+
On the Langflow welcome screen, click the **New Flow** button and then create **Blank Flow**:
63+
![New Flow screen - Blank Flow](../images/langflow/new_blank_flow.png)
64+
65+
Now, we can start building our flow.
66+
67+
### Calling Apify Actors in Langflow
68+
69+
To call Apify Actors in Langflow, we need to add the **Apify Actors** component to the flow.
70+
From the bundle menu, add **Apify Actors** component:
71+
![Flow - Add Apify Actors](../images/langflow/bundles_apify.png)
72+
73+
Next, we need to configure the Apify Actors components. First, input your API token (learn how to get it [here](https://docs.apify.com/platform/integrations/api)). Then, set the Actor ID of the component to `apify/rag-web-browser` to use the [RAG Web Browser](https://apify.com/apify/rag-web-browser). Set the **Run input** field to pass arguments to the Actor run, allowing it to search Google with the query `"what is monero?"` (full Actor input schema can be found [here](https://apify.com/apify/rag-web-browser/input-schema)):
74+
75+
```json
76+
{"query": "what is monero?", "maxResults": 3}
77+
```
78+
79+
Now, we can run the component by clicking the **Run** button.
80+
![Flow - Apify Actors Run](../images/langflow/apify_actors_run.png)
81+
82+
Once the run is finished, we can view the output by clicking the **Output** button.
83+
![Flow - Apify Actors Output](../images/langflow/apify_actors_output.png)
84+
85+
The output should look similar to this:
86+
![Flow - Apify Actors Output Data](../images/langflow/apify_actors_output_data.png)
87+
88+
To filter only the `metadata` and `markdown` fields, set **Output fields** to `metadata,markdown`. Additionally, enable **Flatten output** by setting it to `true`. This will output only the metadata and text content from the search results.
89+
> Flattening is necessary when you need to access nested dictionary fields in the output data object; they cannot be accessed directly otherwise in the Data object.
90+
91+
![Flow - Apify Actors Output Filter](../images/langflow/apify_actors_output_filter.png)
92+
93+
When you run the component again, the output contains only the `markdown` and flattened `metadata` fields:
94+
95+
![Flow - Apify Actors Output Filtered](../images/langflow/apify_actors_output_data_filtered.png)
96+
97+
Now that we understand how to call Apify Actors, let's build a practical example where we search for a company's social media profiles and extract data from them.
98+
99+
### Building a flow to search for a company's social media profiles
100+
101+
Create a new flow and add two **Apify Actors** components from the menu.
102+
103+
Input your API token (learn how to get it [here](https://docs.apify.com/platform/integrations/api)) and set the Actor ID of the first component to `apify/google-search-scraper` and the second one to `clockworks/free-tiktok-scraper`:
104+
![Flow - Actors configuration](../images/langflow/apify_actors_configuration.png)
105+
106+
Add the **Agent** component from the menu and set your OpenAI API key (get it [here](https://platform.openai.com/account/api-keys)):
107+
108+
:::tip Optimize Agent results
109+
110+
For better results, switch the model to `gpt-4o` instead of `gpt-4o-mini` in the Agent configuration
111+
112+
:::
113+
114+
![Flow - Agent configuration](../images/langflow/agent_configuration.png)
115+
116+
To be able to interact with the agent, add **Chat Input** and **Chat Output** components from the menu and connect them to the Agent component **Input** and **Response**.
117+
Then connect both Apify Actor components **Tool** outputs to the Agent component **Tools** input so that the agent can call the Apify Actors. The final flow that can search the web for a company's social media profiles and extract data from them should look like this:
118+
![Flow - Final](../images/langflow/flow.png)
119+
120+
Click the **Playground** button and chat with the agent to test the flow:
121+
![Flow - Playground](../images/langflow/playground.png)
122+
123+
Here is an example agent output for the following query:
124+
125+
```text
126+
find tiktok profile of company openai using google search and then show me the profile bio and their latest video
127+
```
128+
129+
![Flow - agent output](../images/langflow/agent_output.png)
21.8 KB
Loading
347 KB
Loading
42.4 KB
Loading
41.9 KB
Loading
63.5 KB
Loading
54.7 KB
Loading
12.5 KB
Loading
29.1 KB
Loading

0 commit comments

Comments
 (0)