Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions components/noor/actions/send-text-message/send-text-message.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import app from "../../noor.app.mjs";

export default {
key: "noor-send-text-message",
name: "Send Text Message",
description: "Send a message in a thread. [See the documentation](https://usenoor.notion.site/v0-e812ae5e5976420f81232fa1c0316e84)",
version: "0.0.1",
type: "action",
props: {
app,
spaceId: {
propDefinition: [
app,
"spaceId",
],
},
thread: {
propDefinition: [
app,
"thread",
],
},
text: {
propDefinition: [
app,
"text",
],
},
},
async run({ $ }) {
const response = await this.app.sendMessage({
$,
data: {
spaceId: this.spaceId,
thread: this.thread,
text: this.text,
},
});

if (response.error) throw new Error(response?.error);

$.export("$summary", `Successfully sent message to '${this.thread}' thread`);

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

export default {
type: "app",
app: "noor",
propDefinitions: {},
propDefinitions: {
thread: {
type: "string",
label: "Thread",
description: "Thread to where the message will be sent",
},
text: {
type: "string",
label: "Text",
description: "Text of the message",
},
spaceId: {
type: "string",
label: "Space ID",
description: "ID of the space, can be viewed in your space settings",
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://sun.noor.to/api/v0";
},
async _makeRequest(opts = {}) {
const {
$ = this,
path,
headers,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
headers: {
...headers,
"Authorization": `Bearer ${this.$auth.api_key}`,
"Content-Type": "application/json",
},
});
},
async sendMessage(args = {}) {
return this._makeRequest({
method: "post",
path: "/sendMessage",
...args,
});
},
},
};
7 changes: 5 additions & 2 deletions components/noor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/noor",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Noor Components",
"main": "noor.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.0"
}
}
}
5 changes: 4 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.