Skip to content

Commit

Permalink
Merge branch 'master' into gmail-update-verify-client-id
Browse files Browse the repository at this point in the history
  • Loading branch information
michelle0927 authored Sep 16, 2024
2 parents 2f3f255 + 8f91060 commit 7b7ebcd
Show file tree
Hide file tree
Showing 16 changed files with 328 additions and 19 deletions.
51 changes: 51 additions & 0 deletions components/altiria/actions/send-sms/send-sms.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import app from "../../altiria.app.mjs";

export default {
key: "altiria-send-sms",
name: "Send SMS",
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).",
type: "action",
version: "0.0.1",
props: {
app,
destination: {
type: "string[]",
label: "Destination Phone Numbers",
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.",
},
msg: {
type: "string",
label: "Message",
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.",
},
},
methods: {
sendSms(args = {}) {
return this.app.post({
path: "/sendSms",
...args,
});
},
},
async run({ $ }) {
const {
sendSms,
destination,
msg,
} = this;

const response = await sendSms({
$,
data: {
destination,
message: {
msg,
},
},
});

$.export("$summary", "Successfully sent SMS message.");

return response;
},
};
45 changes: 41 additions & 4 deletions components/altiria/altiria.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,48 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "altiria",
propDefinitions: {},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
getUrl(path) {
return `https://www.altiria.net:8443/apirest/ws${path}`;
},
getHeaders(headers) {
return {
...headers,
"Content-Type": "application/json;charset=UTF-8",
"Accept": "application/json",
};
},
getDataAuth(data) {
const {
api_key: apiKey,
api_secret: apiSecret,
} = this.$auth;
return {
...data,
credentials: {
apiKey,
apiSecret,
},
};
},
makeRequest({
$ = this, path, headers, data, ...args
} = {}) {
return axios($, {
...args,
url: this.getUrl(path),
headers: this.getHeaders(headers),
data: this.getDataAuth(data),
});
},
post(args = {}) {
return this.makeRequest({
method: "POST",
...args,
});
},
},
};
};
7 changes: 5 additions & 2 deletions components/altiria/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/altiria",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Altiria Components",
"main": "altiria.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "3.0.1"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import sendbird from "../../sendbird_ai_chabot.app.mjs";

export default {
key: "sendbird_ai_chabot-send-bot-message",
name: "Send Bot Message",
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)",
version: "0.0.1",
type: "action",
props: {
sendbird,
botId: {
propDefinition: [
sendbird,
"botId",
],
},
channelUrl: {
propDefinition: [
sendbird,
"channelUrl",
],
},
message: {
type: "string",
label: "Message",
description: "Specifies the content of the message sent by the bot",
},
},
async run({ $ }) {
const response = await this.sendbird.sendBotMessage({
$,
botId: this.botId,
data: {
channel_url: this.channelUrl,
message: this.message,
},
});
if (response?.message?.message_id) {
$.export("$summary", `Successfully sent message with ID: ${response.message.message_id}`);
}
return response;
},
};
7 changes: 5 additions & 2 deletions components/sendbird_ai_chabot/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/sendbird_ai_chabot",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Sendbird AI chabot Components",
"main": "sendbird_ai_chabot.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.1"
}
}
}
93 changes: 88 additions & 5 deletions components/sendbird_ai_chabot/sendbird_ai_chabot.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,94 @@
import { axios } from "@pipedream/platform";
const DEFAULT_LIMIT = 20;

export default {
type: "app",
app: "sendbird_ai_chabot",
propDefinitions: {},
propDefinitions: {
botId: {
type: "string",
label: "Bot ID",
description: "The identifier of a bot",
async options({ page }) {
const { bots } = await this.listBots({
params: {
limit: DEFAULT_LIMIT,
offset: page * DEFAULT_LIMIT,
},
});
return bots?.map(({ bot }) => ({
label: bot.bot_nickname,
value: bot.bot_userid,
})) || [];
},
},
channelUrl: {
type: "string",
label: "Channel URL",
description: "Specifies the URL of the channel",
async options({ page }) {
const { channels } = await this.listGroupChannels({
params: {
limit: DEFAULT_LIMIT,
offset: page * DEFAULT_LIMIT,
},
});
return channels?.map(({
name: label, channel_url: value,
}) => ({
label,
value,
})) || [];
},
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return `https://api-${this.$auth.application_id}.sendbird.com/v3`;
},
_headers() {
return {
"Api-Token": `${this.$auth.api_token}`,
};
},
_makeRequest({
$ = this,
path,
...args
}) {
return axios($, {
url: `${this._baseUrl()}${path}`,
headers: this._headers(),
...args,
});
},
updateWebhook(opts = {}) {
return this._makeRequest({
method: "PUT",
path: "/applications/settings/webhook",
...opts,
});
},
listBots(opts = {}) {
return this._makeRequest({
path: "/bots",
...opts,
});
},
listGroupChannels(opts = {}) {
return this._makeRequest({
path: "/group_channels",
...opts,
});
},
sendBotMessage({
botId, ...opts
}) {
return this._makeRequest({
method: "POST",
path: `/bots/${botId}/send`,
...opts,
});
},
},
};
};
14 changes: 14 additions & 0 deletions components/sendbird_ai_chabot/sources/common/events.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default [
{
value: "form:submit",
label: "form submitted",
},
{
value: "group_channel:bot_message_send",
label: "bot message sent within group channel",
},
{
value: "group_channel:message_send",
label: "message sent within group channel",
},
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import sendbird from "../../sendbird_ai_chabot.app.mjs";
import events from "../common/events.mjs";

export default {
key: "sendbird_ai_chabot-new-event-received",
name: "New Event Received (Instant)",
description: "Emit new event when a new webhook event is received.",
version: "0.0.1",
type: "source",
dedupe: "unique",
props: {
sendbird,
http: {
type: "$.interface.http",
customResponse: true,
},
events: {
type: "string[]",
label: "Events",
description: "The events to subscribe to",
options: events,
},
},
hooks: {
async activate() {
await this.sendbird.updateWebhook({
data: {
enabled: true,
url: this.http.endpoint,
enabled_events: this.events,
},
});
},
async deactivate() {
await this.sendbird.updateWebhook({
data: {
enabled: false,
url: this.http.endpoint,
enabled_events: [],
},
});
},
},
methods: {
generateMeta(body) {
const ts = Date.now();
return {
id: ts,
summary: `New ${body.category} event`,
ts,
};
},
},
async run(event) {
const { body } = event;
if (!body) {
return;
}
this.http.respond({
status: 200,
});
const meta = this.generateMeta(body);
this.$emit(body, meta);
},
};
1 change: 1 addition & 0 deletions platform/dist/constants.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export declare const DEFAULT_POLLING_SOURCE_TIMER_INTERVAL: number;
export declare const PD_OFFICIAL_GMAIL_OAUTH_CLIENT_ID = "fnd4m13k1mjb6djallp1m9kr7o8kslcu";
3 changes: 2 additions & 1 deletion platform/dist/constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_POLLING_SOURCE_TIMER_INTERVAL = void 0;
exports.PD_OFFICIAL_GMAIL_OAUTH_CLIENT_ID = exports.DEFAULT_POLLING_SOURCE_TIMER_INTERVAL = void 0;
exports.DEFAULT_POLLING_SOURCE_TIMER_INTERVAL = 60 * 15;
exports.PD_OFFICIAL_GMAIL_OAUTH_CLIENT_ID = "fnd4m13k1mjb6djallp1m9kr7o8kslcu";
2 changes: 1 addition & 1 deletion platform/dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export { ConfigurationError, } from "./errors";
export { default as sqlProp, } from "./sql-prop";
export type { ColumnSchema, DbInfo, TableInfo, TableMetadata, TableSchema, } from "./sql-prop";
export { default as sqlProxy, } from "./sql-proxy";
export { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, } from "./constants";
export { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, PD_OFFICIAL_GMAIL_OAUTH_CLIENT_ID, } from "./constants";
export declare const SendConfigEmail: t.PartialC<{
html: t.StringC;
subject: t.StringC;
Expand Down
1 change: 1 addition & 0 deletions platform/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var sql_proxy_1 = require("./sql-proxy");
Object.defineProperty(exports, "sqlProxy", { enumerable: true, get: function () { return sql_proxy_1.default; } });
var constants_1 = require("./constants");
Object.defineProperty(exports, "DEFAULT_POLLING_SOURCE_TIMER_INTERVAL", { enumerable: true, get: function () { return constants_1.DEFAULT_POLLING_SOURCE_TIMER_INTERVAL; } });
Object.defineProperty(exports, "PD_OFFICIAL_GMAIL_OAUTH_CLIENT_ID", { enumerable: true, get: function () { return constants_1.PD_OFFICIAL_GMAIL_OAUTH_CLIENT_ID; } });
const SendPayload = t.union([
t.string,
t.object,
Expand Down
Loading

0 comments on commit 7b7ebcd

Please sign in to comment.