Skip to content

business4s/chatops4s

Repository files navigation

chatops4s

Discord Sonatype Nexus (Snapshots)

chatops4s is a lightweight Scala library that makes building Slack chatops simple enough that you'll actually do it.

See the Website for details and join our Discord for discussions.

Getting started

Add the dependency:

"org.business4s" %% "chatops4s-slack" % "<version>"

Features

  • Simple messaging -- send, reply, update, and delete messages with a clean API
  • Typed interactions -- buttons, slash commands, and forms with compile-time derivation
  • Manifest generation -- validateSetup generates a Slack app manifest and setup instructions so you don't hand-configure anything
  • Socket Mode -- real-time WebSocket connection, no public URL or HTTP server needed

Example

for {
  slack      <- SlackGateway.create(backend)
  approveBtn <- slack.registerButton[String] { click =>
                  slack.update(click.messageId, s"Approved by <@${click.userId}>").void
                }
  rejectBtn  <- slack.registerButton[String] { click =>
                  slack.update(click.messageId, s"Rejected by <@${click.userId}>").void
                }
  _          <- slack.registerCommand[String]("deploy", "Deploy to production") { _ =>
                  slack
                    .send(
                      channel,
                      "Deploy v1.2.3?",
                      Seq(
                        approveBtn.render("Approve", "v1.2.3"),
                        rejectBtn.render("Reject", "v1.2.3"),
                      ),
                    )
                    .as(CommandResponse.Silent)
                }
  _          <- slack.validateSetup("MyApp", "slack-manifest.yml")
  _          <- slack.start(botToken, Some(appToken))
} yield ()

See the full documentation for getting started, interactions, and more.

Releases

No releases published

Packages

 
 
 

Contributors 4

  •  
  •  
  •  
  •  

Languages