Skip to content

Commit cdab94d

Browse files
committed
[ACTION] Microsoft Teams Bot - Reply to Message - WIP
1 parent fb62fb3 commit cdab94d

File tree

5 files changed

+142
-6
lines changed

5 files changed

+142
-6
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import app from "../../microsoft_teams_bot.app.mjs";
2+
3+
export default {
4+
key: "microsoft_teams_bot-reply-to-message",
5+
name: "Reply To Message",
6+
description: "Reply to a message in Microsoft Teams. [See the documentation](https://learn.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-connector-quickstart?view=azure-bot-service-4.0#reply-to-the-users-message).",
7+
type: "action",
8+
version: "0.0.1",
9+
props: {
10+
app,
11+
baseUrl: {
12+
type: "string",
13+
label: "Base URL",
14+
description: "The URL of the service. Eg. `https://smba.trafficmanager.net`.",
15+
},
16+
text: {
17+
type: "string",
18+
label: "Text",
19+
description: "The text of the message to send.",
20+
},
21+
fromRecipientId: {
22+
type: "string",
23+
label: "From Recipient ID",
24+
description: "The ID of the recipient of the message.",
25+
},
26+
fromRecipientName: {
27+
type: "string",
28+
label: "From Recipient Name",
29+
description: "The name of the recipient of the message.",
30+
},
31+
conversationId: {
32+
type: "string",
33+
label: "Conversation ID",
34+
description: "The ID of the conversation.",
35+
},
36+
toRecipientId: {
37+
type: "string",
38+
label: "To Recipient ID",
39+
description: "The ID of the recipient of the message.",
40+
},
41+
toRecipientName: {
42+
type: "string",
43+
label: "To Recipient Name",
44+
description: "The name of the recipient of the message.",
45+
},
46+
replyToId: {
47+
type: "string",
48+
label: "Reply To ID",
49+
description: "The ID of the message to reply to.",
50+
},
51+
},
52+
methods: {
53+
replyToMessage({
54+
incommingMessageConversationId, incomingMessageId, ...args
55+
} = {}) {
56+
return this.app.post({
57+
path: `/conversations/${incommingMessageConversationId}/activities/${incomingMessageId}`,
58+
...args,
59+
});
60+
},
61+
},
62+
async run({ $ }) {
63+
const {
64+
replyToMessage,
65+
baseUrl,
66+
text,
67+
fromRecipientId,
68+
fromRecipientName,
69+
conversationId,
70+
toRecipientId,
71+
toRecipientName,
72+
replyToId,
73+
} = this;
74+
75+
const response = await replyToMessage({
76+
$,
77+
baseUrl,
78+
data: {
79+
type: "message",
80+
from: {
81+
id: fromRecipientId,
82+
name: fromRecipientName,
83+
},
84+
conversation: {
85+
id: conversationId,
86+
},
87+
recipient: {
88+
id: toRecipientId,
89+
name: toRecipientName,
90+
},
91+
text,
92+
replyToId,
93+
},
94+
});
95+
96+
$.export("$summary", "Successfully replied to message.");
97+
98+
return response;
99+
},
100+
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const VERSION_PATH = "/teams/v3";
2+
3+
export default {
4+
VERSION_PATH,
5+
};
Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,35 @@
1+
import { axios } from "@pipedream/platform";
2+
import constants from "./common/constants.mjs";
3+
14
export default {
25
type: "app",
36
app: "microsoft_teams_bot",
47
propDefinitions: {},
58
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
9+
getUrl(baseUrl, path) {
10+
return `${baseUrl}${constants.VERSION_PATH}${path}`;
11+
},
12+
getHeaders(headers) {
13+
return {
14+
...headers,
15+
"Content-Type": "application/json",
16+
"Authorization": `Bearer ${this.$auth.oauth_access_token}`,
17+
};
18+
},
19+
makeRequest({
20+
$ = this, baseUrl, path, headers, ...args
21+
} = {}) {
22+
return axios($, {
23+
url: this.getUrl(baseUrl, path),
24+
headers: this.getHeaders(headers),
25+
...args,
26+
});
27+
},
28+
post(args = {}) {
29+
return this.makeRequest({
30+
method: "POST",
31+
...args,
32+
});
933
},
1034
},
1135
};

components/microsoft_teams_bot/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/microsoft_teams_bot",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Microsoft Teams Bot Components",
55
"main": "microsoft_teams_bot.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.0.3"
1417
}
15-
}
18+
}

pnpm-lock.yaml

Lines changed: 5 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)