1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "workflow_json": {
12 "name": "Demo order sync",
13 "nodes": [
14 {
15 "id": "1",
16 "name": "Webhook",
17 "type": "n8n-nodes-base.webhook",
18 "typeVersion": 1,
19 "position": [
20 0,
21 0
22 ],
23 "parameters": {
24 "path": "orders",
25 "httpMethod": "POST"
26 }
27 },
28 {
29 "id": "2",
30 "name": "Send to CRM",
31 "type": "n8n-nodes-base.httpRequest",
32 "typeVersion": 4,
33 "position": [
34 250,
35 0
36 ],
37 "parameters": {
38 "method": "POST",
39 "url": "https://crm.example.com/api/orders"
40 }
41 }
42 ],
43 "connections": {
44 "Webhook": {
45 "main": [
46 [
47 {
48 "node": "Send to CRM",
49 "type": "main",
50 "index": 0
51 }
52 ]
53 ]
54 }
55 },
56 "active": true
57 }
58};
59
60
61const run = await client.actor("colt2822/n8n-workflow-autopsy").call(input);
62
63
64console.log('Results from dataset');
65console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
66const { items } = await client.dataset(run.defaultDatasetId).listItems();
67items.forEach((item) => {
68 console.dir(item);
69});
70
71