Skip to content

feat(methods): add chat.postMessage example - #48

Merged
zimeg merged 12 commits into
mainfrom
methods-typecheck-only
Aug 14, 2026
Merged

feat(methods): add chat.postMessage example#48
zimeg merged 12 commits into
mainfrom
methods-typecheck-only

Conversation

@zimeg

@zimeg zimeg commented Jul 14, 2026

Copy link
Copy Markdown
Member

Summary

Adds a methods/ chat.postMessage example to the Bolt for Java examples — the first entry in a new methods/ showcase of individual Slack Web API method calls with slack-api-client.

  • src/main/java/chat/ChatPostMessage.java reads a token from the environment, initializes a MethodsClient, builds a ChatPostMessageRequest, and calls chatPostMessage directly in main.
  • The example ships a manifest.json requesting only chat:write.
  • methods/README.md documents the family and links the implementation; the top-level README lists the new showcase.

The example is validated in CI by compilation and Spotless (Palantir) formatting — the strongly-typed ChatPostMessageRequest builder catches wrong or misspelled arguments at compile time.

Testing

From methods/:

export SLACK_TOKEN="xoxb-..."
slack install --environment local
mvn compile exec:java -Dexec.mainClass=chat.ChatPostMessage

Confirm the message posts to the configured channel.


Supersedes the runtime-test / MockWebServer exploration in #47 (closed).

Co-Authored-By: Claude svc-devxp-claude@slack-corp.com

zimeg and others added 4 commits July 14, 2026 16:45
Add a methods/ chat.postMessage example verified by compilation alone,
with no MockWebServer test. Because chatPostMessage and its request
builder are strongly typed, javac catches wrong or misspelled arguments
(e.g. .chnnel(...) -> cannot find symbol) at compile time without a mock
server.

This is an alternative to the MockWebServer runtime-test approach for
side-by-side comparison.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Add the methods example module to the CI matrix. The compile-only example
has no test class; `mvn test` compiles it and runs zero tests, so CI
verifies it builds and passes spotless.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Match the runtime branch: add a chat manifest.json requesting only
chat:write, move the scope out of the README into the manifest, and use the
method's exact docs description.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
zimeg added 4 commits August 11, 2026 20:34
Mirror the bolt-js-examples methods README: tighten the intro, add a
'Making a request' walkthrough, and rename 'What's on display' to
'What's on call'. Keep the Maven layout and run command intact — the
walkthrough runs from the project root (cd methods) where 'mvn compile
exec:java' resolves.
The flexmark markdown formatter (spotless-maven-plugin) requires the
file to end with a blank line; the mirrored README ended on the content
line, failing 'spotless:check' in CI.
Flatten the example to mirror the bolt-js counterpart: perform the
call flow directly in main() rather than delegating to example01().
Java still requires the class and main shell, but the body now reads
top-to-bottom — read the token, initialize the client, call the
method. Drops the now-unused ChatPostMessageResponse import.
Match the methods entry to its README: 'An interface for querying
information from and enacting change in a Slack workspace' rather than
the outdated 'Individual Slack Web API method calls' phrasing.
@zimeg zimeg added new PR only - a new app is being introduced java Pull requests that update java code documentation Improvements or additions to documentation labels Aug 12, 2026
@zimeg zimeg self-assigned this Aug 12, 2026
@zimeg zimeg changed the title feat(methods): add chat.postMessage example (compile-only) feat(methods): add chat.postMessage example Aug 12, 2026
zimeg and others added 3 commits August 11, 2026 22:31
The example reads one variable (SLACK_TOKEN), so 'an environment
variable' is more accurate than the plural.
Add the exec-maven-plugin so `mvn exec:java` actually runs the class,
and disable cleanupDaemonThreads so the run exits promptly instead of
hanging on the SDK's background threads. Capture and print the response
so a run shows its outcome.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
The docs link lives in the methods README (source of truth); the per-file
class comment was redundant and used a malformed {@link URL}. Removing it
keeps the example set uniform (no per-class doc comments).

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>

@zimeg zimeg left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☕ Words on these changes but otherwise we're matching format of adjacent:

Comment thread methods/pom.xml
Comment on lines +70 to +76
<dependencies>
<dependency>
<groupId>com.slack.api</groupId>
<artifactId>slack-api-client</artifactId>
<version>1.49.0</version>
</dependency>
</dependencies>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📣 note: We keep this in pom.xml format for ease of testing! Instructions will follow once stable:

🔗 https://docs.slack.dev/tools/java-slack-sdk/guides/web-api-client-setup#build-from-source

Comment thread methods/README.md

```sh
$ cd methods # Navigate to the project root
$ slack app settings # Create an app

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🪬 note: This is vague but an included manifest can be found nested in methods.

Comment thread methods/pom.xml
Comment on lines +22 to +29
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<cleanupDaemonThreads>false</cleanupDaemonThreads>
</configuration>
</plugin>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👁️‍🗨️ note: This speeds up execution or prevents stalled waits but might not be ideal for examples. Because this is a shared configuration file for all methods I'm optimistic we can improve this without significant trouble.

@zimeg
zimeg marked this pull request as ready for review August 14, 2026 23:49
@zimeg
zimeg requested a review from a team as a code owner August 14, 2026 23:49
@zimeg
zimeg merged commit abec2aa into main Aug 14, 2026
4 checks passed
@zimeg
zimeg deleted the methods-typecheck-only branch August 14, 2026 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation java Pull requests that update java code new PR only - a new app is being introduced

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant