1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "items": [
12 {
13 "product": "Wireless earbuds",
14 "review": "Battery lasts all day and pairing was instant. Best purchase this year!",
15 "rating": 5
16 },
17 {
18 "product": "Wireless earbuds",
19 "review": "Left earbud stopped working after two weeks. Support never answered my emails.",
20 "rating": 1
21 },
22 {
23 "product": "Coffee grinder",
24 "review": "Grinds evenly but it is louder than I expected. Fine for the price.",
25 "rating": 3
26 },
27 {
28 "product": "Coffee grinder",
29 "review": "Package arrived three days late and the box was crushed, but the grinder itself works.",
30 "rating": 3
31 },
32 {
33 "product": "Desk lamp",
34 "review": "Lámpara preciosa, luz cálida y muy buena calidad. La recomiendo.",
35 "rating": 5
36 }
37 ],
38 "maxRows": 5,
39 "prompt": `Analyze this customer review.
40Product: {{product}}
41Stars: {{rating}}
42Review: {{review}}`,
43 "outputMode": "json",
44 "outputFields": {
45 "sentiment": "positive|negative|neutral|mixed",
46 "mainTopic": "short topic, e.g. battery, shipping, noise, quality",
47 "needsReply": "boolean - true if customer support should respond",
48 "replyDraft": "one polite sentence the shop could reply with, in the review's language"
49 }
50};
51
52
53const run = await client.actor("gazidev/bulk-ai-dataset-enricher").call(input);
54
55
56console.log('Results from dataset');
57console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
58const { items } = await client.dataset(run.defaultDatasetId).listItems();
59items.forEach((item) => {
60 console.dir(item);
61});
62
63