linklater: The fast and fun way to write bots

[ bsd3, library, network ] [ Propose Tags ]

A library for writing Slack chat bots.


Features you could take advantage of right now, should you choose:

For example, maybe you want this little guy to show up in your channel:

Find out how by clicking on Network.Linklater!

[Skip to Readme]
Versions [faq],,,,,,,,,,,,
Change log changelog
Dependencies aeson (>= && <0.8), base (>=4.6 && <4.8), bytestring (>= && <0.11), containers (==0.5.*), http-types (>=0.8.5 && <0.9), lens (==4.3.*), text (>= && <1.2), wai (>= && <3.1), wreq (>= && <0.2) [details]
License BSD-3-Clause
Author Hao Lian <>
Revised Revision 1 made by hao at 2014-07-27T08:22:27Z
Category Network
Home page
Bug tracker
Source repo head: git clone
Uploaded by hao at 2014-07-27T08:15:30Z
Distributions NixOS:
Downloads 8402 total (7 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Successful builds reported [all 1 reports]





Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info


Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

For package maintainers and hackage trustees

Readme for linklater-

[back to package description]

Who let you in here?

Relax! I'm here to make your life easier. Has your company ever switched to using Slack, and then you wanted to write silly Slack bots in Haskell as a way to learn Haskell?

<sup>Really?<sup>Wow<sup>That was a pretty specific question.</sup></sup>

Uh, do you want to be friends? Well let's talk about it later, because right now I have an example for you.

But you'll have to grab me first:

  • cabal sandbox init
  • cabal install linklater

If you don't have Haskell, it's quite easy: Windows, Mac, and Linux.

Show me an example!

Here's a /jpgto bot. If you run this program and then tell Slack about your server (incoming hook and custom slash command) and then type /jpgto diplomatico in one of your channels, you'll get the image from How, you say? Screen scraping.

-- Remaining imports left as an exercise to the reader.
import Network.Linklater (say, slashSimple, Command(..), Config(..), Message(..), Icon(..), Format(..))

findUrl :: Text -> Maybe Text
findUrl = fmap fromStrict . maybeResult . parse (manyTill (notChar '\n') (string "src=\"") *> takeTill (== '"'))

jpgto :: Maybe Command -> IO Text
jpgto (Just (Command user channel (Just text))) = do
  message <- (fmap messageOf . findUrl . decodeUtf8 . flip (^.) responseBody) <$> get ("http://" <> (unpack subdomain) <> "")
  case (debug, message) of
    (True, _) -> putStrLn ("+ Pretending to post " <> (unpack . decodeUtf8 . encode) message) >> return ""
    (False, Just m) -> config' >>= say m >> return ""
    (False, Nothing) -> return "Something went wrong!"
  where config' = (Config "" . filter (/= '\n') . pack) <$> readFile "token"
        subdomain = (intercalate "." . fmap (filter isLetter . filter isAscii) . words) text
        messageOf url = FormattedMessage (EmojiIcon "gift") "jpgtobot" channel [FormatAt user, FormatLink url (subdomain <> ">")]
        debug = True
jpgto _ = return "Type more! (Did you know? jpgtobot is only 26 lines of Haskell. <>)"

main :: IO ()
main = let port = 3000 in putStrLn ("+ Listening on port " <> show port) >> run port (slashSimple jpgto)

For the full example (since this one is missing a ton of imports), see the examples/ directory on GitHub.

Now! /jpgto corgi:

jpgtobot in action

So easy. Much fast.


  • Uses Text everywhere so you can send your slash commands crazy Unicode characters all day long.
  • Lovely documentation.
  • Battle-tested.


  • Hao Lian, author
  • Ian Henry, design review and future contributor???
  • Shields (the Grizzly Bear album), which I listened all the way through for the first time while I was writing this ★★★★