Skip to content

Commit d7a650a

Browse files
authored
feat(tools): added apify block/tools (#2136)
* feat(tools): added apify * cleanup
1 parent a8f87f7 commit d7a650a

File tree

12 files changed

+873
-1442
lines changed

12 files changed

+873
-1442
lines changed

apps/docs/components/icons.tsx

Lines changed: 126 additions & 721 deletions
Large diffs are not rendered by default.

apps/docs/components/ui/icon-mapping.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import type { ComponentType, SVGProps } from 'react'
66
import {
77
AirtableIcon,
8+
ApifyIcon,
89
ApolloIcon,
910
ArxivIcon,
1011
AsanaIcon,
@@ -187,5 +188,6 @@ export const blockTypeToIconMap: Record<string, IconComponent> = {
187188
asana: AsanaIcon,
188189
arxiv: ArxivIcon,
189190
apollo: ApolloIcon,
191+
apify: ApifyIcon,
190192
airtable: AirtableIcon,
191193
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
title: Apify
3+
description: Run Apify actors and retrieve results
4+
---
5+
6+
import { BlockInfoCard } from "@/components/ui/block-info-card"
7+
8+
<BlockInfoCard
9+
type="apify"
10+
color="#E0E0E0"
11+
/>
12+
13+
{/* MANUAL-CONTENT-START:intro */}
14+
[Apify](https://apify.com/) is a powerful platform for building, deploying, and running web automation and web scraping actors at scale. Apify enables you to extract useful data from any website, automate workflows, and connect your data pipelines seamlessly.
15+
16+
With Apify, you can:
17+
18+
- **Run ready-made or custom actors**: Integrate public actors or develop your own, automating a wide range of web data extraction and browser tasks.
19+
- **Retrieve datasets**: Access and manage structured datasets collected by actors in real time.
20+
- **Scale web automation**: Leverage cloud infrastructure to run tasks reliably, asynchronously or synchronously, with robust error handling.
21+
22+
In Sim, the Apify integration allows your agents to perform core Apify operations programmatically:
23+
24+
- **Run Actor (Sync)**: Use `apify_run_actor_sync` to launch an Apify actor and wait for its completion, retrieving the results as soon as the run finishes.
25+
- **Run Actor (Async)**: Use `apify_run_actor_async` to start an actor in the background and periodically poll for results, suitable for longer or complex jobs.
26+
27+
These operations equip your agents to automate, scrape, and orchestrate data collection or browser automation tasks directly inside workflows — all with flexible configuration and result handling, without the need for manual runs or external tools. Integrate Apify as a dynamic automation and data-extraction engine that programmatically powers your agents' web-scale workflows.
28+
{/* MANUAL-CONTENT-END */}
29+
30+
31+
## Usage Instructions
32+
33+
Integrate Apify into your workflow. Run any Apify actor with custom input and retrieve results. Supports both synchronous and asynchronous execution with automatic dataset fetching.
34+
35+
36+
37+
## Tools
38+
39+
### `apify_run_actor_sync`
40+
41+
Run an APIFY actor synchronously and get results (max 5 minutes)
42+
43+
#### Input
44+
45+
| Parameter | Type | Required | Description |
46+
| --------- | ---- | -------- | ----------- |
47+
| `apiKey` | string | Yes | APIFY API token from console.apify.com/account#/integrations |
48+
| `actorId` | string | Yes | Actor ID or username/actor-name \(e.g., "janedoe/my-actor" or actor ID\) |
49+
| `input` | string | No | Actor input as JSON string. See actor documentation for required fields. |
50+
| `timeout` | number | No | Timeout in seconds \(default: actor default\) |
51+
| `build` | string | No | Actor build to run \(e.g., "latest", "beta", or build tag/number\) |
52+
53+
#### Output
54+
55+
| Parameter | Type | Description |
56+
| --------- | ---- | ----------- |
57+
| `success` | boolean | Whether the actor run succeeded |
58+
| `runId` | string | APIFY run ID |
59+
| `status` | string | Run status \(SUCCEEDED, FAILED, etc.\) |
60+
| `datasetId` | string | Dataset ID containing results |
61+
| `items` | array | Dataset items \(if completed\) |
62+
63+
### `apify_run_actor_async`
64+
65+
Run an APIFY actor asynchronously with polling for long-running tasks
66+
67+
#### Input
68+
69+
| Parameter | Type | Required | Description |
70+
| --------- | ---- | -------- | ----------- |
71+
| `apiKey` | string | Yes | APIFY API token from console.apify.com/account#/integrations |
72+
| `actorId` | string | Yes | Actor ID or username/actor-name \(e.g., "janedoe/my-actor" or actor ID\) |
73+
| `input` | string | No | Actor input as JSON string |
74+
| `waitForFinish` | number | No | Initial wait time in seconds \(0-60\) before polling starts |
75+
| `itemLimit` | number | No | Max dataset items to fetch \(1-250000, default 100\) |
76+
| `timeout` | number | No | Timeout in seconds \(default: actor default\) |
77+
| `build` | string | No | Actor build to run \(e.g., "latest", "beta", or build tag/number\) |
78+
79+
#### Output
80+
81+
| Parameter | Type | Description |
82+
| --------- | ---- | ----------- |
83+
| `success` | boolean | Whether the actor run succeeded |
84+
| `runId` | string | APIFY run ID |
85+
| `status` | string | Run status \(SUCCEEDED, FAILED, etc.\) |
86+
| `datasetId` | string | Dataset ID containing results |
87+
| `items` | array | Dataset items \(if completed\) |
88+
89+
90+
91+
## Notes
92+
93+
- Category: `tools`
94+
- Type: `apify`

apps/docs/content/docs/en/tools/meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"pages": [
33
"index",
44
"airtable",
5+
"apify",
56
"apollo",
67
"arxiv",
78
"asana",

apps/sim/blocks/blocks/apify.ts

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
import { ApifyIcon } from '@/components/icons'
2+
import type { BlockConfig } from '@/blocks/types'
3+
import type { RunActorResult } from '@/tools/apify/types'
4+
5+
export const ApifyBlock: BlockConfig<RunActorResult> = {
6+
type: 'apify',
7+
name: 'Apify',
8+
description: 'Run Apify actors and retrieve results',
9+
longDescription:
10+
'Integrate Apify into your workflow. Run any Apify actor with custom input and retrieve results. Supports both synchronous and asynchronous execution with automatic dataset fetching.',
11+
docsLink: 'https://docs.sim.ai/tools/apify',
12+
category: 'tools',
13+
bgColor: '#E0E0E0',
14+
icon: ApifyIcon,
15+
16+
subBlocks: [
17+
{
18+
id: 'operation',
19+
title: 'Operation',
20+
type: 'dropdown',
21+
options: [
22+
{ label: 'Run Actor', id: 'apify_run_actor_sync' },
23+
{ label: 'Run Actor (Async)', id: 'apify_run_actor_async' },
24+
],
25+
value: () => 'apify_run_actor_sync',
26+
},
27+
{
28+
id: 'apiKey',
29+
title: 'Apify API Token',
30+
type: 'short-input',
31+
password: true,
32+
placeholder: 'Enter your Apify API token',
33+
required: true,
34+
},
35+
{
36+
id: 'actorId',
37+
title: 'Actor ID',
38+
type: 'short-input',
39+
placeholder: 'e.g., janedoe/my-actor or actor ID',
40+
required: true,
41+
},
42+
{
43+
id: 'input',
44+
title: 'Actor Input',
45+
type: 'code',
46+
language: 'json',
47+
placeholder: '{\n "startUrl": "https://example.com",\n "maxPages": 10\n}',
48+
required: false,
49+
},
50+
{
51+
id: 'timeout',
52+
title: 'Timeout',
53+
type: 'short-input',
54+
placeholder: 'Actor timeout in seconds',
55+
required: false,
56+
},
57+
{
58+
id: 'build',
59+
title: 'Build',
60+
type: 'short-input',
61+
placeholder: 'Actor build (e.g., "latest", "beta", or build tag)',
62+
required: false,
63+
},
64+
{
65+
id: 'waitForFinish',
66+
title: 'Wait For Finish',
67+
type: 'short-input',
68+
placeholder: 'Initial wait time in seconds (0-60)',
69+
required: false,
70+
condition: {
71+
field: 'operation',
72+
value: 'apify_run_actor_async',
73+
},
74+
},
75+
{
76+
id: 'itemLimit',
77+
title: 'Item Limit',
78+
type: 'short-input',
79+
placeholder: 'Max dataset items to fetch (1-250000)',
80+
required: false,
81+
condition: {
82+
field: 'operation',
83+
value: 'apify_run_actor_async',
84+
},
85+
},
86+
],
87+
88+
tools: {
89+
access: ['apify_run_actor_sync', 'apify_run_actor_async'],
90+
config: {
91+
tool: (params) => params.operation,
92+
params: (params: Record<string, any>) => {
93+
const { operation, ...rest } = params
94+
const result: Record<string, any> = {
95+
apiKey: rest.apiKey,
96+
actorId: rest.actorId,
97+
}
98+
99+
if (rest.input) {
100+
result.input = rest.input
101+
}
102+
103+
if (rest.timeout) {
104+
result.timeout = Number(rest.timeout)
105+
}
106+
107+
if (rest.build) {
108+
result.build = rest.build
109+
}
110+
111+
if (rest.waitForFinish) {
112+
result.waitForFinish = Number(rest.waitForFinish)
113+
}
114+
115+
if (rest.itemLimit) {
116+
result.itemLimit = Number(rest.itemLimit)
117+
}
118+
119+
return result
120+
},
121+
},
122+
},
123+
124+
inputs: {
125+
operation: { type: 'string', description: 'Operation to perform' },
126+
apiKey: { type: 'string', description: 'Apify API token' },
127+
actorId: { type: 'string', description: 'Actor ID or username/actor-name' },
128+
input: { type: 'string', description: 'Actor input as JSON string' },
129+
timeout: { type: 'number', description: 'Timeout in seconds' },
130+
build: { type: 'string', description: 'Actor build version' },
131+
waitForFinish: { type: 'number', description: 'Initial wait time in seconds' },
132+
itemLimit: { type: 'number', description: 'Max dataset items to fetch' },
133+
},
134+
135+
outputs: {
136+
success: { type: 'boolean', description: 'Whether the actor run succeeded' },
137+
runId: { type: 'string', description: 'Apify run ID' },
138+
status: { type: 'string', description: 'Run status (SUCCEEDED, FAILED, etc.)' },
139+
datasetId: { type: 'string', description: 'Dataset ID containing results' },
140+
items: { type: 'json', description: 'Dataset items (if completed)' },
141+
},
142+
}

apps/sim/blocks/registry.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { AgentBlock } from '@/blocks/blocks/agent'
22
import { AirtableBlock } from '@/blocks/blocks/airtable'
33
import { ApiBlock } from '@/blocks/blocks/api'
44
import { ApiTriggerBlock } from '@/blocks/blocks/api_trigger'
5+
import { ApifyBlock } from '@/blocks/blocks/apify'
56
import { ApolloBlock } from '@/blocks/blocks/apollo'
67
import { ArxivBlock } from '@/blocks/blocks/arxiv'
78
import { AsanaBlock } from '@/blocks/blocks/asana'
@@ -119,6 +120,7 @@ import type { BlockConfig } from '@/blocks/types'
119120
export const registry: Record<string, BlockConfig> = {
120121
agent: AgentBlock,
121122
airtable: AirtableBlock,
123+
apify: ApifyBlock,
122124
apollo: ApolloBlock,
123125
api: ApiBlock,
124126
arxiv: ArxivBlock,

0 commit comments

Comments
 (0)