@pipedream/microsoft_teams 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,33 @@
1
+ import microsoftTeams from "../../microsoft_teams.app.mjs";
2
+
3
+ export default {
4
+ key: "microsoft_teams-get-current-user",
5
+ name: "Get Current User",
6
+ description: "Returns the authenticated Microsoft Teams user's ID, display name, email, and principal name via Microsoft Graph. Call this first when the user says 'my channels', 'my chats', or needs identity context. Use the returned `id` to identify the sender in **Send Channel Message** or **Send Chat Message** results. [See the documentation](https://learn.microsoft.com/en-us/graph/api/user-get).",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: true,
13
+ },
14
+ props: {
15
+ microsoftTeams,
16
+ },
17
+ async run({ $ }) {
18
+ const user = await this.microsoftTeams.client()
19
+ .api("/me")
20
+ .select("id,displayName,mail,userPrincipalName")
21
+ .get();
22
+
23
+ const summaryName = user.displayName || user.mail || user.id;
24
+ $.export("$summary", `Retrieved user ${summaryName}`);
25
+
26
+ return {
27
+ id: user.id,
28
+ displayName: user.displayName,
29
+ mail: user.mail,
30
+ userPrincipalName: user.userPrincipalName,
31
+ };
32
+ },
33
+ };
@@ -3,9 +3,9 @@ import microsoftTeams from "../../microsoft_teams.app.mjs";
3
3
  export default {
4
4
  key: "microsoft_teams-send-channel-message",
5
5
  name: "Send Channel Message",
6
- description: "Send a message to a team's channel. [See the docs here](https://docs.microsoft.com/en-us/graph/api/channel-post-messages?view=graph-rest-1.0&tabs=http)",
6
+ description: "Send a message to a team's channel. Optionally include inline images via `hostedContents`. [See the documentation](https://learn.microsoft.com/en-us/graph/api/chatmessage-post?view=graph-rest-1.0&tabs=http)",
7
7
  type: "action",
8
- version: "0.0.12",
8
+ version: "0.1.0",
9
9
  annotations: {
10
10
  destructiveHint: false,
11
11
  openWorldHint: true,
@@ -40,6 +40,12 @@ export default {
40
40
  "contentType",
41
41
  ],
42
42
  },
43
+ hostedContents: {
44
+ type: "string[]",
45
+ label: "Hosted Contents",
46
+ description: "An array of JSON strings, each representing an inline hosted image to attach. Each item must be a JSON object with `'@microsoft.graph.temporaryId'` (string), `contentBytes` (base64-encoded image data), and `contentType` (MIME type, e.g. `image/png`). Example: `{\"@microsoft.graph.temporaryId\": \"1\", \"contentBytes\": \"BASE64_STRING\", \"contentType\": \"image/png\"}`. Reference each image in your HTML message body using `<img src=\"../hostedContents/1/$value\">`. [See the docs](https://learn.microsoft.com/en-us/graph/api/chatmessage-post?view=graph-rest-1.0&tabs=http#example-6-send-inline-images-along-with-the-message)",
47
+ optional: true,
48
+ },
43
49
  },
44
50
  async run({ $ }) {
45
51
  const {
@@ -47,22 +53,32 @@ export default {
47
53
  channelId,
48
54
  message,
49
55
  contentType,
56
+ hostedContents,
50
57
  } = this;
51
58
 
52
- const response =
53
- await this.microsoftTeams.sendChannelMessage({
54
- teamId,
55
- channelId,
56
- content: {
57
- body: {
58
- content: message,
59
- contentType,
60
- },
61
- },
62
- });
59
+ const parsedHostedContents = hostedContents?.map((item) =>
60
+ typeof item === "string"
61
+ ? JSON.parse(item)
62
+ : item);
63
63
 
64
- $.export("$summary", `Successfully sent message to channel ${channelId}`);
64
+ const content = {
65
+ body: {
66
+ content: message,
67
+ contentType: contentType ?? "text",
68
+ },
69
+ };
65
70
 
71
+ if (parsedHostedContents?.length) {
72
+ content.hostedContents = parsedHostedContents;
73
+ }
74
+
75
+ const response = await this.microsoftTeams.sendChannelMessage({
76
+ teamId,
77
+ channelId,
78
+ content,
79
+ });
80
+
81
+ $.export("$summary", `Successfully sent message to channel ${channelId}`);
66
82
  return response;
67
83
  },
68
84
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/microsoft_teams",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Pipedream Microsoft Teams Components",
5
5
  "main": "microsoft_teams.app.mjs",
6
6
  "keywords": [