1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "blueprintJson": {
12 "name": "Sample - order intake to CRM",
13 "flow": [
14 {
15 "id": 1,
16 "module": "google-sheets:watchRows",
17 "version": 2,
18 "parameters": {
19 "__IMTCONN__": 1000001,
20 "limit": 100
21 },
22 "mapper": {
23 "mode": "select",
24 "spreadsheetId": "SAMPLE_SHEET_ID",
25 "sheetId": "Orders"
26 },
27 "metadata": {
28 "designer": {
29 "x": 0,
30 "y": 0
31 },
32 "parameters": [
33 {
34 "name": "__IMTCONN__",
35 "type": "account:google",
36 "label": "Connection"
37 }
38 ]
39 }
40 },
41 {
42 "id": 2,
43 "module": "builtin:BasicRouter",
44 "version": 1,
45 "metadata": {
46 "designer": {
47 "x": 300,
48 "y": 0
49 }
50 },
51 "routes": [
52 {
53 "flow": [
54 {
55 "id": 3,
56 "module": "http:ActionSendData",
57 "version": 3,
58 "parameters": {
59 "handleErrors": false
60 },
61 "mapper": {
62 "url": "https://api.example.com/v1/orders",
63 "method": "post",
64 "headers": [
65 {
66 "name": "Authorization",
67 "value": "Bearer sk-proj-SAMPLEONLYnotarealkey0123456789abcdefgh"
68 }
69 ],
70 "qs": [],
71 "rejectUnauthorized": true
72 },
73 "metadata": {
74 "designer": {
75 "x": 600,
76 "y": -150
77 }
78 },
79 "onerror": [
80 {
81 "id": 6,
82 "module": "builtin:Break",
83 "version": 1,
84 "metadata": {
85 "designer": {}
86 }
87 }
88 ]
89 }
90 ]
91 },
92 {
93 "flow": [
94 {
95 "id": 4,
96 "module": "builtin:BasicFeeder",
97 "version": 1,
98 "mapper": {
99 "array": "{{1.line_items}}"
100 },
101 "metadata": {
102 "designer": {
103 "x": 600,
104 "y": 150
105 }
106 }
107 },
108 {
109 "id": 5,
110 "module": "airtable:ActionCreateRecord",
111 "version": 3,
112 "parameters": {
113 "__IMTCONN__": 1000002
114 },
115 "mapper": {
116 "baseId": "SAMPLE_BASE",
117 "table": "Line items",
118 "record": {
119 "Name": "{{4.sku}}"
120 }
121 },
122 "metadata": {
123 "designer": {
124 "x": 900,
125 "y": 150
126 }
127 }
128 }
129 ]
130 }
131 ]
132 }
133 ],
134 "metadata": {
135 "version": 1,
136 "scenario": {
137 "roundtrips": 1,
138 "maxErrors": 3,
139 "autoCommit": true,
140 "autoCommitTriggerLast": true,
141 "sequential": false,
142 "slots": null,
143 "confidential": false,
144 "dataloss": false,
145 "dlq": false,
146 "freshVariables": false
147 },
148 "designer": {
149 "orphans": []
150 }
151 }
152 }
153};
154
155
156const run = await client.actor("mediocre_interest/make-scenario-backup").call(input);
157
158
159console.log('Results from dataset');
160console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
161const { items } = await client.dataset(run.defaultDatasetId).listItems();
162items.forEach((item) => {
163 console.dir(item);
164});
165
166