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 "Hi, I've been trying to connect my Stripe account for 3 days and the integration keeps failing. I'm losing sales. Please help ASAP.",
13 {
14 "subject": "Invoice question",
15 "body": "Can you send me the invoice for August? No rush."
16 },
17 "How much does the enterprise plan cost for 50 seats?"
18 ],
19 "questions": {
20 "department": {
21 "type": "choice",
22 "instructions": "Which team should handle this message?",
23 "criteria": {
24 "billing": "Payments, invoicing, refunds, subscription charges",
25 "technical": "Bugs, outages, integrations, errors",
26 "sales": "Pricing, upgrades, new accounts, plan questions"
27 }
28 },
29 "frustration": {
30 "type": "score",
31 "instructions": "How frustrated does the customer appear?",
32 "criteria": [
33 "Calm, just stating facts",
34 "Frustrated but civil",
35 "Very angry, strong language"
36 ]
37 },
38 "is_urgent": {
39 "type": "noul",
40 "instructions": "Does the message convey urgency or time-sensitivity?",
41 "criteria": {
42 "true": "Explicitly time-sensitive or blocking",
43 "false": "No urgency expressed"
44 }
45 }
46 }
47};
48
49
50const run = await client.actor("sameh.jarour/jev-classifier").call(input);
51
52
53console.log('Results from dataset');
54console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
55const { items } = await client.dataset(run.defaultDatasetId).listItems();
56items.forEach((item) => {
57 console.dir(item);
58});
59
60