https://github.com/gianluz/slackalo
A Kotlin library to build and send Slack messages via Slack webhook url
https://github.com/gianluz/slackalo
Last synced: 4 days ago
JSON representation
A Kotlin library to build and send Slack messages via Slack webhook url
- Host: GitHub
- URL: https://github.com/gianluz/slackalo
- Owner: gianluz
- License: mit
- Created: 2020-04-28T20:45:44.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-27T17:18:13.000Z (almost 6 years ago)
- Last Synced: 2025-03-01T14:31:27.397Z (over 1 year ago)
- Language: Kotlin
- Size: 181 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://search.maven.org/search?q=g:%22com.gianluz%22%20AND%20a:%22slackalo%22)
A Kotlin library to build and send Slack messages via Slack webhook
## Dependency
Slackalo is available in maven central
```groovy
dependencies {
implementation 'com.gianluz:slackalo:1.0'
}
```
## Introduction
Build your custom slack message just using the builder utils provided.
Checkout the official Slack Block Kit Builder [here](https://api.slack.com/tools/block-kit-builder?mode=message)
Slackalo doesn't provide all the blocks right now, but you can contribute to make it more complete!
Here you can find a list of what currently Slackalo support:
- `Section` as `PlainText` or `MarkdownText` only
- `Image` as `ImageBlock`
- Section with `Fields` as `FieldsBlock`
- Section with `Image` as `ImagePlainTextBlock` or `ImageMarkdownBlock`
- `Divider` as `Divider`
## Usage
To create a slack webhook url please follow the official slack app guide [here](https://api.slack.com/messaging/webhooks)
Here an example:
```kotlin
val message = slackMessage {
blocks {
plainText("Hello this is a plaintext")
markdown("Hello this is a markdown")
divider()
imageMarkdown(
":warning: This is a message with an image and slack emoji",
"https://api.slack.com/img/blocks/bkb_template_images/palmtree.png",
"alt text"
)
divider()
fields {
markdown("Field 1")
markdown("Field 2")
markdown("Field 3")
}
}
}
with(DefaultWebHookClient()) {
sendWebHook("MySlackWebHookUrl", message)
}
```
## Contribute
Please fork this repo, and add all the new functionalities you would like to have and open a Pull request!