Haskell SDK for LINE Messaging API.
A Servant library for building LINE chatbots. This package is composed of the following modules:
A client library for the LINE Messaging API, including the
Line
monad, which manages the channel credentials.A servant combinator to write safe Line webhooks.
To get started, see the documentation for the Line.Bot.Client
and Line.Bot.Webhook
modules below.
line-bot-sdk
Servant library for building LINE chatbots.
Features:
Servant combinator
LineReqBody
for validation of request signatures using the channel secret. This is required to distinguish legitimate requests sent by LINE from malicious requestsBindings for (most of) the Messaging APIs
Installation
From Hackage
line-bot-sdk
is available on Hackage. Using the cabal-install
tool:
cabal update
cabal install line-bot-sdk
From source
Building from source can be done using stack or cabal:
git clone github.com/moleike/line-bot-sdk.git
cd line-bot-sdk
stack install # Alternatively, `cabal install`
Documentation
See the official API documentation for more information.
- English: https://developers.line.biz/en/docs/messaging-api/overview/
- Japanese: https://developers.line.biz/ja/docs/messaging-api/overview/
Usage
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE OverloadedStrings #-}
import Data.String (fromString)
import Line.Bot.Client
import Line.Bot.Types
import System.Environment (getEnv)
getProfiles :: Id Room -> Line [Profile]
getProfiles roomId = do
userIds <- getRoomMemberUserIds roomId
sequence $ getRoomMemberProfile roomId <$> userIds
main = do
token <- fromString <$> getEnv "CHANNEL_TOKEN"
result <- runLine (getProfiles "U4af4980629...") token
case result of
Left err -> print err
Right profile -> print profile
See the examples/ directory for more comprehensive examples.
Contribute
Please report bugs via the github issue tracker.
Acknowledgments
Thanks to the authors of servant-github, for inspiration.