Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions methods/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ $ mvn compile exec:java -Dexec.mainClass=chat.ChatPostMessage # Make the reques

### chat

- **[chat.appendStream](https://docs.slack.dev/reference/methods/chat.appendStream)**: Appends text to an existing streaming conversation. [Implementation](./src/main/java/chat/ChatAppendStream.java).
- **[chat.postMessage](https://docs.slack.dev/reference/methods/chat.postmessage)**: Sends a message to a channel. [Implementation](./src/main/java/chat/ChatPostMessage.java).
- **[chat.startStream](https://docs.slack.dev/reference/methods/chat.startStream)**: Starts a new streaming conversation. [Implementation](./src/main/java/chat/ChatStartStream.java).
- **[chat.stopStream](https://docs.slack.dev/reference/methods/chat.stopStream)**: Stops a streaming conversation. [Implementation](./src/main/java/chat/ChatStopStream.java).

30 changes: 30 additions & 0 deletions methods/src/main/java/chat/ChatAppendStream.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package chat;

import com.slack.api.Slack;
import com.slack.api.methods.MethodsClient;
import com.slack.api.methods.SlackApiException;
import com.slack.api.methods.request.chat.ChatAppendStreamRequest;
import com.slack.api.methods.response.chat.ChatAppendStreamResponse;
import java.io.IOException;

public class ChatAppendStream {

public static void main(String[] args) throws IOException, SlackApiException {
// Read a token from an environment variable
String token = System.getenv("SLACK_TOKEN");

// Initialize
MethodsClient methods = Slack.getInstance().methods(token);

// Call the chat.appendStream method
ChatAppendStreamRequest request = ChatAppendStreamRequest.builder()
.channel("C123ABC456")
.ts("1234567890.123456")
.markdownText(" — reading the logs now")
.build();
ChatAppendStreamResponse response = methods.chatAppendStream(request);

// Inspect the response
System.out.println(response);
}
}
30 changes: 30 additions & 0 deletions methods/src/main/java/chat/ChatStartStream.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package chat;

import com.slack.api.Slack;
import com.slack.api.methods.MethodsClient;
import com.slack.api.methods.SlackApiException;
import com.slack.api.methods.request.chat.ChatStartStreamRequest;
import com.slack.api.methods.response.chat.ChatStartStreamResponse;
import java.io.IOException;

public class ChatStartStream {

public static void main(String[] args) throws IOException, SlackApiException {
// Read a token from an environment variable
String token = System.getenv("SLACK_TOKEN");

// Initialize
MethodsClient methods = Slack.getInstance().methods(token);

// Call the chat.startStream method
ChatStartStreamRequest request = ChatStartStreamRequest.builder()
.channel("C123ABC456")
.threadTs("1234567890.123456")
.markdownText("Let me look into that")
.build();
ChatStartStreamResponse response = methods.chatStartStream(request);

// Inspect the response
System.out.println(response);
}
}
29 changes: 29 additions & 0 deletions methods/src/main/java/chat/ChatStopStream.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package chat;

import com.slack.api.Slack;
import com.slack.api.methods.MethodsClient;
import com.slack.api.methods.SlackApiException;
import com.slack.api.methods.request.chat.ChatStopStreamRequest;
import com.slack.api.methods.response.chat.ChatStopStreamResponse;
import java.io.IOException;

public class ChatStopStream {

public static void main(String[] args) throws IOException, SlackApiException {
// Read a token from an environment variable
String token = System.getenv("SLACK_TOKEN");

// Initialize
MethodsClient methods = Slack.getInstance().methods(token);

// Call the chat.stopStream method
ChatStopStreamRequest request = ChatStopStreamRequest.builder()
.channel("C123ABC456")
.ts("1234567890.123456")
.build();
ChatStopStreamResponse response = methods.chatStopStream(request);

// Inspect the response
System.out.println(response);
}
}