@slack/web-api / ChatStreamer
Defined in: packages/web-api/src/chat-stream.ts:15
new ChatStreamer(
client,
logger,
args,
options): ChatStreamer;Defined in: packages/web-api/src/chat-stream.ts:47
Instantiate a new chat streamer.
ChatStreamer
The "constructor" method creates a unique ChatStreamer instance that keeps track of one chat stream.
const client = new WebClient(process.env.SLACK_BOT_TOKEN);
const logger = new ConsoleLogger();
const args = {
channel: "C0123456789",
thread_ts: "1700000001.123456",
recipient_team_id: "T0123456789",
recipient_user_id: "U0123456789",
};
const streamer = new ChatStreamer(client, logger, args, { buffer_size: 512 });
await streamer.append({
markdown_text: "**hello world!**",
});
await streamer.stop();- https://docs.slack.dev/reference/methods/chat.startStream
- https://docs.slack.dev/reference/methods/chat.appendStream
- https://docs.slack.dev/reference/methods/chat.stopStream
get ts(): string | undefined;Defined in: packages/web-api/src/chat-stream.ts:62
The message timestamp of the stream. Returns undefined until the first flush
(when chat.startStream is called).
https://docs.slack.dev/reference/methods/chat.update
string | undefined
append(args): Promise<
| ChatAppendStreamResponse
| ChatStartStreamResponse
| null>;Defined in: packages/web-api/src/chat-stream.ts:86
Append to the stream.
Omit<ChatAppendStreamArguments, "channel" | "ts">
Promise<
| ChatAppendStreamResponse
| ChatStartStreamResponse
| null>
The "append" method appends to the chat stream being used. This method can be called multiple times. After the stream is stopped this method cannot be called.
const streamer = client.chatStream({
channel: "C0123456789",
thread_ts: "1700000001.123456",
recipient_team_id: "T0123456789",
recipient_user_id: "U0123456789",
});
await streamer.append({
markdown_text: "**hello wo",
});
await streamer.append({
markdown_text: "rld!**",
});
await streamer.stop();https://docs.slack.dev/reference/methods/chat.appendStream
stop(args?): Promise<ChatStopStreamResponse>;Defined in: packages/web-api/src/chat-stream.ts:132
Stop the stream and finalize the message.
Omit<ChatStopStreamArguments, "channel" | "ts">
Promise<ChatStopStreamResponse>
The "stop" method stops the chat stream being used. This method can be called once to end the stream. Additional "blocks" and "metadata" can be provided.
const streamer = client.chatStream({
channel: "C0123456789",
thread_ts: "1700000001.123456",
recipient_team_id: "T0123456789",
recipient_user_id: "U0123456789",
});
await streamer.append({
markdown_text: "**hello world!**",
});
await streamer.stop();