License | BSD3 |
---|---|
Maintainer | Marcello Seri <marcello.seri@gmail.com> |
Stability | experimental |
Portability | unknown |
Safe Haskell | None |
Language | Haskell2010 |
This module contains a servant
client for the
Messenger Platform API
and helpers useful to construct the appropriate requests and parse the responses.
- getUserProfileInfo :: Maybe Token -> Text -> Manager -> IO (Either ServantError UserProfileResponse)
- removeWelcomeMessage :: Maybe Token -> Text -> Manager -> IO (Either ServantError WelcomeMessageResponse)
- sendTextMessage :: Maybe Token -> SendTextMessageRequest -> Manager -> IO (Either ServantError MessageResponse)
- sendStructuredMessage :: Maybe Token -> SendStructuredMessageRequest -> Manager -> IO (Either ServantError MessageResponse)
- setWelcomeMessage :: Maybe Token -> Text -> WelcomeMessageRequest -> Manager -> IO (Either ServantError WelcomeMessageResponse)
- subscribedApps :: Maybe Token -> Manager -> IO (Either ServantError SubscriptionResponse)
- uploadImageMessage :: Maybe Token -> UploadImageMessageRequest FileUpload -> Manager -> IO (Either ServantError MessageResponse)
- api :: Proxy FBMessengerSendAPI
- type FBMessengerSendAPI = (GraphAPIAccessToken :> ("messages" :> (ReqBody `[JSON]` SendTextMessageRequest :> Post `[JSON]` MessageResponse))) :<|> ((GraphAPIAccessToken :> ("messages" :> (MultipartFormDataReqBody (UploadImageMessageRequest FileUpload) :> Post `[JSON]` MessageResponse))) :<|> ((GraphAPIAccessToken :> ("messages" :> (ReqBody `[JSON]` SendStructuredMessageRequest :> Post `[JSON]` MessageResponse))) :<|> ((GraphAPIAccessToken :> ("subscribed_apps" :> Post `[JSON]` SubscriptionResponse)) :<|> ((GraphAPIAccessToken :> (Capture "page_id" Text :> ("thread_settings" :> (ReqBody `[JSON]` WelcomeMessageRequest :> Post `[JSON]` WelcomeMessageResponse)))) :<|> ((GraphAPIAccessToken :> (Capture "page_id" Text :> ("thread_settings" :> (ReqBody `[JSON]` WelcomeMessageRequest :> Delete `[JSON]` WelcomeMessageResponse)))) :<|> (GraphAPIAccessToken :> (QueryParam "fields" Text :> (Capture "user_id" Text :> Get `[JSON]` UserProfileResponse))))))))
- newtype Token = Token Text
Functions
getUserProfileInfo :: Maybe Token -> Text -> Manager -> IO (Either ServantError UserProfileResponse) Source
Get the profile informations of a user. In addition to the token, you need to provide the user_id. Return a record containing the profile informations.
removeWelcomeMessage :: Maybe Token -> Text -> Manager -> IO (Either ServantError WelcomeMessageResponse) Source
Remove the welcome message. In addition to the token, you need to provide the facebook page_id. Return a simple object containing a string indicating if the welcome message is correctly removed.
sendTextMessage :: Maybe Token -> SendTextMessageRequest -> Manager -> IO (Either ServantError MessageResponse) Source
Send text messages. On success, minor informations on the sent message are returned.
sendStructuredMessage :: Maybe Token -> SendStructuredMessageRequest -> Manager -> IO (Either ServantError MessageResponse) Source
Send a structured messages. This can be an image message (containing an image url) or any template message (generic, button, receipt). On success, minor informations on the sent message are returned.
setWelcomeMessage :: Maybe Token -> Text -> WelcomeMessageRequest -> Manager -> IO (Either ServantError WelcomeMessageResponse) Source
Set a welcome message, this can be an image message (containing an image url) or any template message (generic, button, receipt). In addition to the token and the message request, you need to provide the facebook page_id. Return a simple object containing a string indicating if the welcome message is correctly registered.
subscribedApps :: Maybe Token -> Manager -> IO (Either ServantError SubscriptionResponse) Source
Test if your bot's auth token is enabled. Requires no parameters. Return a simple object containing a boolean value indicating if the token is correctly registered.
uploadImageMessage :: Maybe Token -> UploadImageMessageRequest FileUpload -> Manager -> IO (Either ServantError MessageResponse) Source
Upload an image and send a structured messages containing it. On success, minor informations on the sent message are returned.
API
api :: Proxy FBMessengerSendAPI Source
Proxy for Messenger Platform Bot Send
type FBMessengerSendAPI = (GraphAPIAccessToken :> ("messages" :> (ReqBody `[JSON]` SendTextMessageRequest :> Post `[JSON]` MessageResponse))) :<|> ((GraphAPIAccessToken :> ("messages" :> (MultipartFormDataReqBody (UploadImageMessageRequest FileUpload) :> Post `[JSON]` MessageResponse))) :<|> ((GraphAPIAccessToken :> ("messages" :> (ReqBody `[JSON]` SendStructuredMessageRequest :> Post `[JSON]` MessageResponse))) :<|> ((GraphAPIAccessToken :> ("subscribed_apps" :> Post `[JSON]` SubscriptionResponse)) :<|> ((GraphAPIAccessToken :> (Capture "page_id" Text :> ("thread_settings" :> (ReqBody `[JSON]` WelcomeMessageRequest :> Post `[JSON]` WelcomeMessageResponse)))) :<|> ((GraphAPIAccessToken :> (Capture "page_id" Text :> ("thread_settings" :> (ReqBody `[JSON]` WelcomeMessageRequest :> Delete `[JSON]` WelcomeMessageResponse)))) :<|> (GraphAPIAccessToken :> (QueryParam "fields" Text :> (Capture "user_id" Text :> Get `[JSON]` UserProfileResponse)))))))) Source
Messenger Platform Send API