@pipedream/slack_v2 1.1.4 → 1.1.5
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.
|
@@ -10,8 +10,9 @@ export default {
|
|
|
10
10
|
+ " To post a note to yourself (save a personal note or reminder), pass your own user ID (e.g. `U1234567890`) as the Channel — use **Get Current User** to find your user ID first."
|
|
11
11
|
+ " To reply to a thread, provide `threadTs` (Slack calls this `thread_ts`) from **Get Channel History**."
|
|
12
12
|
+ " Supports plain text with Slack mrkdwn formatting and Block Kit blocks."
|
|
13
|
+
+ " Posts as the authenticated user by default; set `sendAsBot` to `true` to post as the Slack app's bot user instead."
|
|
13
14
|
+ " [See the documentation](https://api.slack.com/methods/chat.postMessage)",
|
|
14
|
-
version: "0.0
|
|
15
|
+
version: "0.1.0",
|
|
15
16
|
type: "action",
|
|
16
17
|
ai: "optimized",
|
|
17
18
|
annotations: {
|
|
@@ -71,6 +72,13 @@ export default {
|
|
|
71
72
|
default: true,
|
|
72
73
|
optional: true,
|
|
73
74
|
},
|
|
75
|
+
sendAsBot: {
|
|
76
|
+
type: "boolean",
|
|
77
|
+
label: "Send as Bot",
|
|
78
|
+
description: "Set to `true` to post the message as the Slack app's bot user instead of the authenticated user. The app is added to the channel automatically if it is not already a member (not possible for DMs). The bot cannot DM a user who has not opened its Messages tab. Defaults to `false` (posts as the authenticated user).",
|
|
79
|
+
default: false,
|
|
80
|
+
optional: true,
|
|
81
|
+
},
|
|
74
82
|
},
|
|
75
83
|
async run({ $ }) {
|
|
76
84
|
// chat.postMessage accepts channel names directly — no ID resolution needed
|
|
@@ -93,6 +101,20 @@ export default {
|
|
|
93
101
|
args.thread_ts = this.threadTs;
|
|
94
102
|
args.reply_broadcast = this.replyBroadcast;
|
|
95
103
|
}
|
|
104
|
+
// as_user: false routes the request through the bot token (see makeRequest).
|
|
105
|
+
// Omitting it keeps the default: post as the authenticated user.
|
|
106
|
+
if (this.sendAsBot) {
|
|
107
|
+
// conversations.invite needs a channel ID, so resolve names first. Skip user IDs:
|
|
108
|
+
// the app can't be added to a DM, and chat.postMessage opens the bot DM itself.
|
|
109
|
+
if (!/^[UW][A-Z0-9]{8,}$/.test(channel)) {
|
|
110
|
+
const channelId = await this.slack.resolveChannelId(channel);
|
|
111
|
+
await this.slack.maybeAddAppToChannels([
|
|
112
|
+
channelId,
|
|
113
|
+
]);
|
|
114
|
+
args.channel = channelId;
|
|
115
|
+
}
|
|
116
|
+
args.as_user = false;
|
|
117
|
+
}
|
|
96
118
|
const response = await this.slack.postChatMessage(args);
|
|
97
119
|
let permalink;
|
|
98
120
|
try {
|