Skip to content

Commit 0ae3a82

Browse files
authored
DOC-1238 Add slack_post output (#226)
1 parent 0dd6b7d commit 0ae3a82

File tree

3 files changed

+133
-2
lines changed

3 files changed

+133
-2
lines changed

modules/ROOT/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@
269269
*** xref:components:outputs/retry.adoc[]
270270
*** xref:components:outputs/schema_registry.adoc[]
271271
*** xref:components:outputs/sftp.adoc[]
272+
*** xref:components:outputs/slack_post.adoc[]
272273
*** xref:components:outputs/snowflake_put.adoc[]
273274
*** xref:components:outputs/snowflake_streaming.adoc[]
274275
*** xref:components:outputs/socket.adoc[]

modules/components/pages/outputs/ockam_kafka.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Common::
2323
--
2424
```yml
2525
# Common configuration fields, showing default values
26-
input:
26+
output:
2727
label: ""
2828
ockam_kafka:
2929
kafka:
@@ -55,7 +55,7 @@ Advanced::
5555
--
5656
```yml
5757
# All configuration fields, showing default values
58-
input:
58+
output:
5959
label: ""
6060
ockam_kafka:
6161
kafka:
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
= slack_post
2+
// tag::single-source[]
3+
:type: output
4+
5+
component_type_dropdown::[]
6+
7+
Posts a new message to a Slack channel using the Slack API method https://api.slack.com/methods/chat.postMessage[chat.postMessage^].
8+
9+
ifndef::env-cloud[]
10+
Introduced in version 4.52.0.
11+
endif::[]
12+
13+
```yml
14+
# Common configuration fields, showing default values
15+
output:
16+
label: ""
17+
slack_post:
18+
bot_token: "" # No default (required)
19+
channel_id: "" # No default (required)
20+
thread_ts: "" # No default (optional)
21+
text: "" # No default (optional)
22+
blocks: "" # No default (optional)
23+
markdown: true
24+
unfurl_links: false
25+
unfurl_media: true
26+
link_names: 0
27+
```
28+
29+
See also: <<Examples, Examples>>
30+
31+
== Fields
32+
33+
=== `bot_token`
34+
35+
Your Slack bot user's OAuth token, which must have the correct permissions to post messages to the target Slack channel.
36+
37+
*Type*: `string`
38+
39+
=== `channel_id`
40+
41+
The encoded ID of the target Slack channel. This field supports xref:configuration:interpolation.adoc#bloblang-queries[interpolation functions].
42+
43+
*Type*: `string`
44+
45+
=== `thread_ts`
46+
47+
Specify the thread timestamp (`ts` value) of another message to post a reply within the same thread. This field supports xref:configuration:interpolation.adoc#bloblang-queries[interpolation functions].
48+
49+
*Type*: `string`
50+
51+
*Default*: `""`
52+
53+
=== `text`
54+
55+
The text content of the message. This field supports xref:configuration:interpolation.adoc#bloblang-queries[interpolation functions].
56+
57+
You can either specify message content in the `text` or `blocks` fields, but not both.
58+
59+
*Type*: `string`
60+
61+
*Default*: `""`
62+
63+
=== `blocks`
64+
65+
A Bloblang query that should return a JSON array of https://api.slack.com/reference/block-kit/blocks[Slack blocks^].
66+
67+
You can either specify message content in the `text` or `blocks` fields, but not both.
68+
69+
*Type*: `string`
70+
71+
=== `markdown`
72+
73+
When set to `true`, this output accepts message content in Markdown format.
74+
75+
*Type*: `bool`
76+
77+
*Default*: `true`
78+
79+
=== `unfurl_links`
80+
81+
When set to `true`, this output provides previews of linked content in Slack messages. For more information about unfurling links, see the https://api.slack.com/reference/messaging/link-unfurling[Slack documentation^].
82+
83+
*Type*: `bool`
84+
85+
*Default*: `false`
86+
87+
=== `unfurl_media`
88+
89+
When set to `true`, this output provides previews of rich content in Slack messages, such as videos or embedded tweets.
90+
91+
*Type*: `bool`
92+
93+
*Default*: `true`
94+
95+
=== `link_names`
96+
97+
When set to `1`, this output finds and links to https://api.slack.com/reference/surfaces/formatting#mentioning-groups[user groups^] mentioned in Slack messages.
98+
99+
*Type*: `bool`
100+
101+
*Default*: `0`
102+
103+
== Examples
104+
105+
The following pipeline reposts messages created by a Slack app to the same thread in the same channel, adding `ECHO:` to the original message text. All hidden or non-message events, and any activity originating from the Slack bot, are excluded.
106+
107+
```yml
108+
input:
109+
slack:
110+
app_token: "${APP_TOKEN:xapp-demo}"
111+
bot_token: "${BOT_TOKEN:xoxb-demo}"
112+
pipeline:
113+
processors:
114+
# Ignore hidden or non-message events, and messages sent by the bot.
115+
- mutation: |
116+
if this.event.type != "message" || (this.event.hidden | false) {
117+
root = deleted()
118+
}
119+
if this.authorizations.any(auth -> auth.user_id == this.event.user) {
120+
root = deleted()
121+
}
122+
output:
123+
slack_post:
124+
bot_token: "${BOT_TOKEN:xoxb-demo}"
125+
channel_id: "${!this.event.channel}"
126+
thread_ts: "${!this.event.ts}"
127+
text: "ECHO: ${!this.event.text}"
128+
```
129+
130+
// end::single-source[]

0 commit comments

Comments
 (0)