Haskell message bot framework https://github.com/airalab/habit#readme

Latest on Hackage:

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.

BSD3 licensed by Alexander Krupenkin
Maintained by mail@akru.me

Haskell Bot it :: Message bot framework

Build Status Build status Hackage Hackage Dependencies Haskell Programming Language BSD3 License


$ git clone https://github.com/airalab/habit && cd habit
$ stack setup
$ stack ghci

Run your story

The Story is an abstraction about sparsed data getted from user though dialogue.

helloStory :: Story a
helloStory _ = hello <$> question "How your name?"
                     <*> question "How your surname?"
                     <*> question "How old are you?"

As you see the story handler hello is apply though the questions to user responses.

type Name    = Text
type Surname = Text
type Age     = Int

hello :: Monad m => Name -> Surname -> Age -> m BotMessage
hello name surname age = do
    return . toMessage $ "Hello, " <> name <> " " <> surname <> "!\n"
                      <> "You lost " <> (pack $ show age) <> " years =)"

To run the Story simple pass it to storyBot as value of mapping between command an story. APIToken type class defines token for given platform, e.g. Telegram platform.

instance APIToken Telegram where
    apiToken = "bot..."

main :: IO ()
main = runBot myBot
  where myBot :: Bot Telegram ()
        myBot = storyBot helpMsg [("/hello", helloStory)]

Full example text.

comments powered byDisqus