Skip to content

Commit 7b7ebcd

Browse files
authored
Merge branch 'master' into gmail-update-verify-client-id
2 parents 2f3f255 + 8f91060 commit 7b7ebcd

File tree

16 files changed

+328
-19
lines changed

16 files changed

+328
-19
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import app from "../../altiria.app.mjs";
2+
3+
export default {
4+
key: "altiria-send-sms",
5+
name: "Send SMS",
6+
description: "Send an SMS message. The message will be sent to the phone numbers you specify. [See the documentation](https://static.altiria.com/especificaciones/altiria_push_rest.pdf).",
7+
type: "action",
8+
version: "0.0.1",
9+
props: {
10+
app,
11+
destination: {
12+
type: "string[]",
13+
label: "Destination Phone Numbers",
14+
description: "The phone numbers to which the message will be sent. Each number will be specified in international numbering format without the prefix `00` or the sign `+`. Eg: `34645852126`. It is essential to include the country prefix (`34` for Spain) so that the message reaches the expected destination. It must not exceed 16 digits. In any case, it is recommended not to exceed **100** phone numbers per request.",
15+
},
16+
msg: {
17+
type: "string",
18+
label: "Message",
19+
description: "Message to send. The list of valid characters and the maximum allowed length is detailed in section 2.4 of the [documentation](https://static.altiria.com/especificaciones/altiria_push_rest.pdf). It cannot be empty (empty string). Mobile web identifiers can be added to generate unique shortened links in the message body. See section 2.5 for more details on mobile webs.",
20+
},
21+
},
22+
methods: {
23+
sendSms(args = {}) {
24+
return this.app.post({
25+
path: "/sendSms",
26+
...args,
27+
});
28+
},
29+
},
30+
async run({ $ }) {
31+
const {
32+
sendSms,
33+
destination,
34+
msg,
35+
} = this;
36+
37+
const response = await sendSms({
38+
$,
39+
data: {
40+
destination,
41+
message: {
42+
msg,
43+
},
44+
},
45+
});
46+
47+
$.export("$summary", "Successfully sent SMS message.");
48+
49+
return response;
50+
},
51+
};

components/altiria/altiria.app.mjs

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,48 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "altiria",
46
propDefinitions: {},
57
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
8+
getUrl(path) {
9+
return `https://www.altiria.net:8443/apirest/ws${path}`;
10+
},
11+
getHeaders(headers) {
12+
return {
13+
...headers,
14+
"Content-Type": "application/json;charset=UTF-8",
15+
"Accept": "application/json",
16+
};
17+
},
18+
getDataAuth(data) {
19+
const {
20+
api_key: apiKey,
21+
api_secret: apiSecret,
22+
} = this.$auth;
23+
return {
24+
...data,
25+
credentials: {
26+
apiKey,
27+
apiSecret,
28+
},
29+
};
30+
},
31+
makeRequest({
32+
$ = this, path, headers, data, ...args
33+
} = {}) {
34+
return axios($, {
35+
...args,
36+
url: this.getUrl(path),
37+
headers: this.getHeaders(headers),
38+
data: this.getDataAuth(data),
39+
});
40+
},
41+
post(args = {}) {
42+
return this.makeRequest({
43+
method: "POST",
44+
...args,
45+
});
946
},
1047
},
11-
};
48+
};

components/altiria/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/altiria",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Altiria Components",
55
"main": "altiria.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "3.0.1"
1417
}
15-
}
18+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import sendbird from "../../sendbird_ai_chabot.app.mjs";
2+
3+
export default {
4+
key: "sendbird_ai_chabot-send-bot-message",
5+
name: "Send Bot Message",
6+
description: "Sends a bot message to a group channel. [See the documentation](https://sendbird.com/docs/chat/platform-api/v3/bot/sending-a-bot-message/send-a-bot-message)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
sendbird,
11+
botId: {
12+
propDefinition: [
13+
sendbird,
14+
"botId",
15+
],
16+
},
17+
channelUrl: {
18+
propDefinition: [
19+
sendbird,
20+
"channelUrl",
21+
],
22+
},
23+
message: {
24+
type: "string",
25+
label: "Message",
26+
description: "Specifies the content of the message sent by the bot",
27+
},
28+
},
29+
async run({ $ }) {
30+
const response = await this.sendbird.sendBotMessage({
31+
$,
32+
botId: this.botId,
33+
data: {
34+
channel_url: this.channelUrl,
35+
message: this.message,
36+
},
37+
});
38+
if (response?.message?.message_id) {
39+
$.export("$summary", `Successfully sent message with ID: ${response.message.message_id}`);
40+
}
41+
return response;
42+
},
43+
};

components/sendbird_ai_chabot/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/sendbird_ai_chabot",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Sendbird AI chabot Components",
55
"main": "sendbird_ai_chabot.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.1"
1417
}
15-
}
18+
}
Lines changed: 88 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,94 @@
1+
import { axios } from "@pipedream/platform";
2+
const DEFAULT_LIMIT = 20;
3+
14
export default {
25
type: "app",
36
app: "sendbird_ai_chabot",
4-
propDefinitions: {},
7+
propDefinitions: {
8+
botId: {
9+
type: "string",
10+
label: "Bot ID",
11+
description: "The identifier of a bot",
12+
async options({ page }) {
13+
const { bots } = await this.listBots({
14+
params: {
15+
limit: DEFAULT_LIMIT,
16+
offset: page * DEFAULT_LIMIT,
17+
},
18+
});
19+
return bots?.map(({ bot }) => ({
20+
label: bot.bot_nickname,
21+
value: bot.bot_userid,
22+
})) || [];
23+
},
24+
},
25+
channelUrl: {
26+
type: "string",
27+
label: "Channel URL",
28+
description: "Specifies the URL of the channel",
29+
async options({ page }) {
30+
const { channels } = await this.listGroupChannels({
31+
params: {
32+
limit: DEFAULT_LIMIT,
33+
offset: page * DEFAULT_LIMIT,
34+
},
35+
});
36+
return channels?.map(({
37+
name: label, channel_url: value,
38+
}) => ({
39+
label,
40+
value,
41+
})) || [];
42+
},
43+
},
44+
},
545
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
46+
_baseUrl() {
47+
return `https://api-${this.$auth.application_id}.sendbird.com/v3`;
48+
},
49+
_headers() {
50+
return {
51+
"Api-Token": `${this.$auth.api_token}`,
52+
};
53+
},
54+
_makeRequest({
55+
$ = this,
56+
path,
57+
...args
58+
}) {
59+
return axios($, {
60+
url: `${this._baseUrl()}${path}`,
61+
headers: this._headers(),
62+
...args,
63+
});
64+
},
65+
updateWebhook(opts = {}) {
66+
return this._makeRequest({
67+
method: "PUT",
68+
path: "/applications/settings/webhook",
69+
...opts,
70+
});
71+
},
72+
listBots(opts = {}) {
73+
return this._makeRequest({
74+
path: "/bots",
75+
...opts,
76+
});
77+
},
78+
listGroupChannels(opts = {}) {
79+
return this._makeRequest({
80+
path: "/group_channels",
81+
...opts,
82+
});
83+
},
84+
sendBotMessage({
85+
botId, ...opts
86+
}) {
87+
return this._makeRequest({
88+
method: "POST",
89+
path: `/bots/${botId}/send`,
90+
...opts,
91+
});
992
},
1093
},
11-
};
94+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export default [
2+
{
3+
value: "form:submit",
4+
label: "form submitted",
5+
},
6+
{
7+
value: "group_channel:bot_message_send",
8+
label: "bot message sent within group channel",
9+
},
10+
{
11+
value: "group_channel:message_send",
12+
label: "message sent within group channel",
13+
},
14+
];
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import sendbird from "../../sendbird_ai_chabot.app.mjs";
2+
import events from "../common/events.mjs";
3+
4+
export default {
5+
key: "sendbird_ai_chabot-new-event-received",
6+
name: "New Event Received (Instant)",
7+
description: "Emit new event when a new webhook event is received.",
8+
version: "0.0.1",
9+
type: "source",
10+
dedupe: "unique",
11+
props: {
12+
sendbird,
13+
http: {
14+
type: "$.interface.http",
15+
customResponse: true,
16+
},
17+
events: {
18+
type: "string[]",
19+
label: "Events",
20+
description: "The events to subscribe to",
21+
options: events,
22+
},
23+
},
24+
hooks: {
25+
async activate() {
26+
await this.sendbird.updateWebhook({
27+
data: {
28+
enabled: true,
29+
url: this.http.endpoint,
30+
enabled_events: this.events,
31+
},
32+
});
33+
},
34+
async deactivate() {
35+
await this.sendbird.updateWebhook({
36+
data: {
37+
enabled: false,
38+
url: this.http.endpoint,
39+
enabled_events: [],
40+
},
41+
});
42+
},
43+
},
44+
methods: {
45+
generateMeta(body) {
46+
const ts = Date.now();
47+
return {
48+
id: ts,
49+
summary: `New ${body.category} event`,
50+
ts,
51+
};
52+
},
53+
},
54+
async run(event) {
55+
const { body } = event;
56+
if (!body) {
57+
return;
58+
}
59+
this.http.respond({
60+
status: 200,
61+
});
62+
const meta = this.generateMeta(body);
63+
this.$emit(body, meta);
64+
},
65+
};

platform/dist/constants.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export declare const DEFAULT_POLLING_SOURCE_TIMER_INTERVAL: number;
2+
export declare const PD_OFFICIAL_GMAIL_OAUTH_CLIENT_ID = "fnd4m13k1mjb6djallp1m9kr7o8kslcu";

platform/dist/constants.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
exports.DEFAULT_POLLING_SOURCE_TIMER_INTERVAL = void 0;
3+
exports.PD_OFFICIAL_GMAIL_OAUTH_CLIENT_ID = exports.DEFAULT_POLLING_SOURCE_TIMER_INTERVAL = void 0;
44
exports.DEFAULT_POLLING_SOURCE_TIMER_INTERVAL = 60 * 15;
5+
exports.PD_OFFICIAL_GMAIL_OAUTH_CLIENT_ID = "fnd4m13k1mjb6djallp1m9kr7o8kslcu";

0 commit comments

Comments
 (0)