Skip to content

Commit cd7da18

Browse files
committed
[ACTION] Clevertap new campaign components
1 parent ee2408b commit cd7da18

File tree

10 files changed

+572
-13
lines changed

10 files changed

+572
-13
lines changed
Lines changed: 303 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,303 @@
1+
import app from "../../clevertap.app.mjs";
2+
import utils from "../../common/utils.mjs";
3+
4+
export default {
5+
key: "clevertap-create-campaign",
6+
name: "Create Campaign",
7+
description: "Create a campaign. [See the documentation](https://developer.clevertap.com/docs/create-campaign-api)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
name: {
13+
type: "string",
14+
label: "Campaign Name",
15+
description: "The name of your campaign shown in the CleverTap dashboard.",
16+
},
17+
targetMode: {
18+
type: "string",
19+
label: "Target Mode",
20+
description: "The type of campaign to create",
21+
options: [
22+
{
23+
label: "Web Push Notification",
24+
value: "webpush",
25+
},
26+
{
27+
label: "Mobile Push Notification",
28+
value: "push",
29+
},
30+
{
31+
label: "Email",
32+
value: "email",
33+
},
34+
{
35+
label: "Webhooks",
36+
value: "webhook",
37+
},
38+
],
39+
},
40+
where: {
41+
type: "object",
42+
label: "Where",
43+
optional: true,
44+
description: `Allows you to filter target base on the user events and profile properties. Omit this parameter to target your entire user base. **Example:**
45+
\`\`\`
46+
{
47+
"event_name": "Charged",
48+
"from": 20250101,
49+
"to": 20250402
50+
}
51+
\`\`\``,
52+
},
53+
content: {
54+
type: "object",
55+
label: "Content",
56+
description: `Object that defines the content for your message. **Web Push Notification Example:**
57+
\`\`\`
58+
{
59+
"title": "Hi!",
60+
"body": "How are you doing today?",
61+
"platform_specific": {
62+
"safari": {
63+
"deep_link": "https://www.google.com",
64+
"ttl": 10
65+
},
66+
"chrome": {
67+
"image": "https://www.exampleImage.com",
68+
"icon": "https://www.exampleIcon.com",
69+
"deep_link": "http://www.example.com",
70+
"ttl": 10,
71+
"require_interaction": true,
72+
"cta_title1": "title",
73+
"cta_link1": "http://www.example2.com",
74+
"cta_iconlink1": "https://www.exampleIcon2.com"
75+
},
76+
"firefox": {
77+
"icon": "https://www.exampleIcon.com",
78+
"deep_link": "https://www.google.com",
79+
"ttl": 10
80+
},
81+
"kaios": {
82+
"icon": "https://www.exampleIcon.com",
83+
"ttl": 10,
84+
"kaiosKV": {
85+
"key1": "value1",
86+
"key2": "value2"
87+
}
88+
}
89+
}
90+
}
91+
\`\`\`\n\n**Mobile Push Notification Example:**
92+
\`\`\`
93+
{
94+
"title": "Hi!",
95+
"body": "How are you doing today?",
96+
"platform_specific": {
97+
"ios": {
98+
"mutable-content": "true",
99+
"deep_link": "example.com",
100+
"sound_file": "example.caf",
101+
"category": "application category//Books",
102+
"badge_count": 1,
103+
"Key": "Value_ios"
104+
},
105+
"android": {
106+
"enable_rendermax": true,
107+
"wzrk_cid": "Marketing",
108+
"background_image": "http://example.jpg",
109+
"default_sound": true,
110+
"deep_link": "example.com",
111+
"large_icon": "http://example.png",
112+
"Key": "Value_android",
113+
}
114+
}
115+
}
116+
\`\`\`\n\n **Email Example:**
117+
\`\`\`
118+
{
119+
"subject": "Welcome",
120+
"body": "<div>Your HTML content for the email</div>",
121+
"sender_name": "CleverTap"
122+
}
123+
\`\`\``,
124+
optional: true,
125+
},
126+
when: {
127+
type: "object",
128+
label: "When",
129+
optional: true,
130+
description: `Allows you to set Date, time and Delivery preferences of the message. **Example:**
131+
\`\`\`
132+
{
133+
"type": "later",
134+
"delivery_date_time": ["20230503 15:20"],
135+
"delivery_timezone": "user",
136+
"user_timezone_wrap_around": true,
137+
"dnd": {
138+
"message_state": "delay",
139+
"dnd_timezone": "user"
140+
},
141+
"campaign_cutoff": "14:20"
142+
}
143+
\`\`\``,
144+
},
145+
respectFrequencyCaps: {
146+
type: "boolean",
147+
label: "Respect Frequency Caps",
148+
description: "Set to `false` if you want to override frequency caps and dwell time. Defaults to `true`.",
149+
optional: true,
150+
},
151+
estimateOnly: {
152+
type: "boolean",
153+
label: "Estimate Only",
154+
description: "If this parameter is set to `true`, the request returns an estimated reach of the campaign, which is the number of users who receive the notification when you send it out. Setting this parameter to `true` does not create the campaign. Defaults to `false`.",
155+
optional: true,
156+
},
157+
conversionGoal: {
158+
type: "object",
159+
label: "Conversion Goal",
160+
optional: true,
161+
description: `Checks the end goal of the campaign for conversion tracking. **Example:**
162+
\`\`\`
163+
{
164+
"event_name": "Charged",
165+
"filter_type": {
166+
"event_property": [
167+
{
168+
"property_name": "Items|Book name",
169+
"operator": "equals",
170+
"property_value": "book name"
171+
},
172+
{
173+
"property_name": "Amount",
174+
"operator": "equals",
175+
"property_value": 3456
176+
},
177+
{
178+
"property_name": "Currency",
179+
"operator": "equals",
180+
"property_value": "USD"
181+
}
182+
],
183+
"first_time": "yes",
184+
"last_time": "yes",
185+
"time_of_day": [["21:00","23:00"],["11:34","12:44"],["13:01","13:40"]],
186+
"day_of_week": [1,7],
187+
"day_of_month": [1,3,16,31]
188+
},
189+
"conversion_time": "1D",
190+
"revenue_property": "Amount"
191+
}
192+
\`\`\``,
193+
},
194+
ttlType: {
195+
type: "string",
196+
label: "Time To Live Type",
197+
description: "This allows setting of time to live for push notifications for android and iOS. The type of time to live. Can be `absolute` or `relative`. Defaults to `absolute`.",
198+
options: [
199+
{
200+
label: "Absolute",
201+
value: "absolute",
202+
},
203+
{
204+
label: "Relative",
205+
value: "relative",
206+
},
207+
],
208+
optional: true,
209+
},
210+
ttlValue: {
211+
type: "integer",
212+
label: "Time To Live Value",
213+
description: "This allows setting of time to live for push notifications for android and iOS. The value of the time to live. Can be a number of days, hours, minutes, or seconds.\n- For `relative` ttl, the input is an integer in minutes\n- For `absolute` ttl, the input should be an integer in the `yyyyMMddHHmm` format. Example: `202207200000`",
214+
optional: true,
215+
},
216+
webhookEndpointName: {
217+
type: "string",
218+
label: "Webhook Endpoint Name",
219+
description: "The name of the webhook endpoint to use for the campaign.",
220+
optional: true,
221+
},
222+
webhookFields: {
223+
type: "string[]",
224+
label: "Webhook Fields",
225+
description: "The fields to include in the webhook payload. Can be `profile-attributes`, `tokens`, or `identities`.",
226+
optional: true,
227+
},
228+
webhookKeyValue: {
229+
type: "object",
230+
label: "Webhook Key Value",
231+
description: "The key-value pairs to include in the webhook payload.",
232+
optional: true,
233+
},
234+
},
235+
async run({ $ }) {
236+
const {
237+
app,
238+
name,
239+
targetMode,
240+
when,
241+
where,
242+
content,
243+
respectFrequencyCaps,
244+
estimateOnly,
245+
conversionGoal,
246+
ttlType,
247+
ttlValue,
248+
webhookEndpointName,
249+
webhookFields,
250+
webhookKeyValue,
251+
} = this;
252+
253+
const response = await app.createCampaign({
254+
$,
255+
data: {
256+
name,
257+
target_mode: targetMode,
258+
respect_frequency_caps: respectFrequencyCaps,
259+
estimate_only: estimateOnly,
260+
when: utils.parseJson(when) || {},
261+
where: utils.parseJson(where) || {},
262+
content: utils.parseJson(content) || {},
263+
...(conversionGoal
264+
? {
265+
conversion_goal: utils.parseJson(conversionGoal),
266+
}
267+
: {}
268+
),
269+
...(ttlType && ttlValue
270+
? {
271+
ttl: {
272+
ttl_type: ttlType,
273+
value: ttlValue,
274+
},
275+
}
276+
: {}
277+
),
278+
...(webhookEndpointName
279+
? {
280+
webhook_endpoint_name: webhookEndpointName,
281+
}
282+
: {}
283+
),
284+
...(webhookFields
285+
? {
286+
webhook_fields: utils.parseJson(webhookFields),
287+
}
288+
: {}
289+
),
290+
...(webhookKeyValue
291+
? {
292+
webhook_key_value: utils.parseJson(webhookKeyValue),
293+
}
294+
: {}
295+
),
296+
},
297+
});
298+
299+
$.export("$summary", "Successfully created campaign");
300+
301+
return response;
302+
},
303+
};

components/clevertap/actions/create-or-update-user/create-or-update-user.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import app from "../../clevertap.app.mjs";
22

33
export default {
44
name: "Create Or Update User",
5-
version: "0.0.1",
5+
version: "0.0.2",
66
key: "clevertap-create-or-update-user",
77
description: "Create or update an user. [See the documentation](https://developer.clevertap.com/docs/upload-user-profiles-api)",
88
type: "action",
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import app from "../../clevertap.app.mjs";
2+
3+
export default {
4+
key: "clevertap-get-campaign-report",
5+
name: "Get Campaign Report",
6+
description: "Get the report for a completed campaign. [See the documentation](https://developer.clevertap.com/docs/get-campaign-report-api)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
from: {
12+
propDefinition: [
13+
app,
14+
"from",
15+
],
16+
},
17+
to: {
18+
propDefinition: [
19+
app,
20+
"to",
21+
],
22+
},
23+
campaignId: {
24+
description: "The ID of the campaign to retrieve the report for.",
25+
propDefinition: [
26+
app,
27+
"campaignId",
28+
({
29+
from, to,
30+
}) => ({
31+
from,
32+
to,
33+
}),
34+
],
35+
},
36+
},
37+
async run({ $ }) {
38+
const {
39+
app,
40+
campaignId,
41+
} = this;
42+
43+
const response = await app.getCampaignReport({
44+
$,
45+
data: {
46+
id: campaignId,
47+
},
48+
});
49+
50+
$.export("$summary", "Successfully retrieved report for campaign");
51+
52+
return response;
53+
},
54+
};

0 commit comments

Comments
 (0)