Skip to content

Commit eea3464

Browse files
committed
[Components] sendblue
1 parent 6845b85 commit eea3464

File tree

8 files changed

+734
-30
lines changed

8 files changed

+734
-30
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import app from "../../sendblue.app.mjs";
2+
3+
export default {
4+
key: "sendblue-get-contact-list",
5+
name: "Get Contact List",
6+
description: "Retrieve a list of your existing contacts from Sendblue. [See the documentation](https://docs.sendblue.com/api/resources/contacts/methods/list)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
},
12+
annotations: {
13+
readOnlyHint: true,
14+
destructiveHint: false,
15+
openWorldHint: true,
16+
},
17+
async run({ $ }) {
18+
const response = await this.app.getContactList({
19+
$,
20+
});
21+
22+
$.export("$summary", "Successfully retrieved contact list");
23+
return response;
24+
},
25+
};
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import app from "../../sendblue.app.mjs";
3+
4+
export default {
5+
key: "sendblue-send-group-message",
6+
name: "Send Group Message",
7+
description: "Send a message to a group of recipients in an iMessage group",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
fromNumber: {
13+
propDefinition: [
14+
app,
15+
"fromNumber",
16+
],
17+
},
18+
groupId: {
19+
propDefinition: [
20+
app,
21+
"groupId",
22+
],
23+
},
24+
toNumbers: {
25+
type: "string[]",
26+
label: "To Numbers",
27+
description: "The phone numbers of the recipients in E.164 format (e.g., `+12025551234`)",
28+
optional: true,
29+
propDefinition: [
30+
app,
31+
"toNumber",
32+
],
33+
},
34+
content: {
35+
propDefinition: [
36+
app,
37+
"content",
38+
],
39+
},
40+
mediaUrl: {
41+
propDefinition: [
42+
app,
43+
"mediaUrl",
44+
],
45+
},
46+
},
47+
annotations: {
48+
readOnlyHint: false,
49+
destructiveHint: false,
50+
openWorldHint: true,
51+
idempotentHint: false,
52+
},
53+
async run({ $ }) {
54+
const {
55+
app,
56+
fromNumber,
57+
groupId,
58+
toNumbers,
59+
content,
60+
mediaUrl,
61+
} = this;
62+
63+
// At least one of toNumbers or groupId is required
64+
if (toNumbers?.length === 0 && !groupId) {
65+
throw new ConfigurationError("At least one of **To Numbers** or **Group ID** is required");
66+
}
67+
68+
const response = await app.sendGroupMessage({
69+
$,
70+
data: {
71+
from_number: fromNumber,
72+
group_id: groupId,
73+
numbers: toNumbers,
74+
content,
75+
media_url: mediaUrl,
76+
},
77+
});
78+
79+
$.export("$summary", "Successfully sent message to group");
80+
return response;
81+
},
82+
};
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import app from "../../sendblue.app.mjs";
2+
3+
export default {
4+
key: "sendblue-send-message",
5+
name: "Send Message",
6+
description: "Send an iMessage or SMS to a specific phone number. [See the documentation](https://docs.sendblue.com/api/resources/messages/methods/send)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
fromNumber: {
12+
propDefinition: [
13+
app,
14+
"fromNumber",
15+
],
16+
},
17+
toNumber: {
18+
propDefinition: [
19+
app,
20+
"toNumber",
21+
],
22+
},
23+
content: {
24+
propDefinition: [
25+
app,
26+
"content",
27+
],
28+
},
29+
mediaUrl: {
30+
propDefinition: [
31+
app,
32+
"mediaUrl",
33+
],
34+
},
35+
sendStyle: {
36+
propDefinition: [
37+
app,
38+
"sendStyle",
39+
],
40+
},
41+
statusCallback: {
42+
propDefinition: [
43+
app,
44+
"statusCallback",
45+
],
46+
},
47+
},
48+
annotations: {
49+
readOnlyHint: false,
50+
destructiveHint: false,
51+
openWorldHint: true,
52+
},
53+
async run({ $ }) {
54+
const {
55+
app,
56+
fromNumber,
57+
toNumber,
58+
content,
59+
mediaUrl,
60+
sendStyle,
61+
statusCallback,
62+
} = this;
63+
64+
const response = await app.sendMessage({
65+
$,
66+
data: {
67+
from_number: fromNumber,
68+
number: toNumber,
69+
content,
70+
media_url: mediaUrl,
71+
send_style: sendStyle,
72+
status_callback: statusCallback,
73+
},
74+
});
75+
76+
$.export("$summary", "Successfully sent message");
77+
return response;
78+
},
79+
};

components/sendblue/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/sendblue",
3-
"version": "0.0.4",
3+
"version": "0.1.0",
44
"description": "Pipedream Sendblue Components",
55
"main": "sendblue.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.1.1"
1417
}
1518
}

0 commit comments

Comments
 (0)