Skip to content

Commit 76845a4

Browse files
authored
New Components - orimon (#11802)
* orimon init * [Components] orimon #11796 Actions - Send Message * pnpm update
1 parent fb2068a commit 76845a4

File tree

4 files changed

+79
-8
lines changed

4 files changed

+79
-8
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import orimon from "../../orimon.app.mjs";
2+
3+
export default {
4+
key: "orimon-send-message",
5+
name: "Send Message to Orimon",
6+
description: "Sends a direct message to Orimon. [See the documentation](https://orimon.gitbook.io/docs/developer-api/message-api)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
orimon,
11+
text: {
12+
type: "string",
13+
label: "Message Text",
14+
description: "The text message you want Orimon to receive.",
15+
},
16+
},
17+
async run({ $ }) {
18+
const tenantId = this.orimon.$auth.tenant_id;
19+
20+
const response = await this.orimon.sendMessage({
21+
$,
22+
data: {
23+
type: "message",
24+
info: {
25+
psid: `${Date.parse(new Date())}_${tenantId}`,
26+
sender: "user",
27+
tenantId: tenantId,
28+
platformName: "web",
29+
},
30+
message: {
31+
id: tenantId,
32+
type: "text",
33+
payload: {
34+
text: this.text,
35+
},
36+
},
37+
},
38+
});
39+
40+
$.export("$summary", "Message sent successfully to Orimon!");
41+
return response;
42+
},
43+
};

components/orimon/orimon.app.mjs

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,32 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "orimon",
4-
propDefinitions: {},
56
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
7+
_baseUrl() {
8+
return "https://channel-connector.orimon.ai/orimon/v1";
9+
},
10+
_headers() {
11+
return {
12+
"Authorization": `apiKey ${this.$auth.api_key}`,
13+
};
14+
},
15+
_makeRequest({
16+
$ = this, path = "/", ...opts
17+
}) {
18+
return axios($, {
19+
url: this._baseUrl() + path,
20+
headers: this._headers(),
21+
...opts,
22+
});
23+
},
24+
sendMessage(opts = {}) {
25+
return this._makeRequest({
26+
method: "POST",
27+
path: "/conversation/api/message",
28+
...opts,
29+
});
930
},
1031
},
11-
};
32+
};

components/orimon/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/orimon",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Orimon Components",
55
"main": "orimon.app.mjs",
66
"keywords": [
@@ -11,5 +11,9 @@
1111
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^1.6.2"
1417
}
15-
}
18+
}
19+

pnpm-lock.yaml

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)