fbmessenger-api-0.1.1.1: High-level bindings to Facebook Messenger Platform API

LicenseBSD3
MaintainerMarcello Seri <marcello.seri@gmail.com>
Stabilityexperimental
Portabilityunknown
Safe HaskellNone
LanguageHaskell2010

Web.FBMessenger.API.Bot.Requests

Contents

Description

This module contains types and helpers to build requests to the Messenger Platform API to use with SendAPI.

Synopsis

Types

data Button Source

Button object for structured messages payloads

Constructors

Button 

Fields

btn_type :: ButtonType

Value is "web_url" or "postback"

btn_title :: Text

Button title

btn_url :: Maybe Text

For web_url buttons, this URL is opened in a mobile browser when the button is tapped. Required if type is "web_url"

btn_payload :: Maybe Text

For postback buttons, this data will be sent back to you via webhook. Required if type is "postback"

data BubbleElement Source

Bubble element object for structured messages payloads

Constructors

BubbleElement 

Fields

elm_title :: Text

Bubble title

elm_item_url :: Maybe Text

URL that is opened when bubble is tapped

elm_image_url :: Maybe Text

Bubble image

elm_subtitle :: Maybe Text

Bubble subtitle

elm_buttons :: Maybe [Button]

Set of buttons that appear as call-to-actions

data FileUpload Source

This object represents data (image, video, ...) with mime type to upload.

Constructors

FileUpload 

Fields

fileUpload_type :: Maybe MimeType

Mime type of the upload.

fileUpload_content :: FileUploadContent

The payload/source to upload.

data FileUploadContent Source

This object represents data (image, video, ...) to upload.

data NotificationType Source

Push notification type for the message

Constructors

Regular

will emit a sound/vibration and a phone notification (default)

SilentPush

will emit a phone notification

NoPush

will not emit either

data Recipient Source

Informations about the recipient of the message

Constructors

Recipient 

Fields

recipient_id :: Maybe Text

ID of recipient

recipient_phone_number :: Maybe Text

Phone number of the recipient with the format +1(212)555-2368

data ReceiptItem Source

Constructors

ReceiptItem 

Fields

re_title :: Text

Title of item

re_subtitle :: Maybe Text

Subtitle of item

re_quantity :: Maybe Int

Quantity of item

re_price :: Maybe Int

Item price

re_currency :: Maybe Text

Currency of price

re_image_url :: Maybe Text

Image URL of item

data ShippingAddress Source

Shipping address object for Receipt Template messages

Constructors

ShippingAddress 

Fields

sa_street_1 :: Text

Street Address, line 1

sa_street_2 :: Maybe Text

Street Address, line 2

sa_city :: Text

City

sa_postal_code :: Text

Postal Code

sa_state :: Text

State abbrevation

sa_country :: Text

Two-letter country abbreviation

data UploadImageMessageRequest payload Source

This object represents request for sendImage

Constructors

UploadImageMessageRequest 

Fields

uiRecipient :: Recipient

Recipient user

uiFileData :: payload

Photo to send. Formats supported: jpg and png.

Functions

bubbleElement :: Text -> BubbleElement Source

Take the bubble element title. The buttons will appear as call-to-action in Messenger. Return a bubble Element

localFileUpload :: FilePath -> FileUpload Source

Return a FileUpload from a given FilePath. At the moment, only png and jpg images are supported by the API.

postbackButton :: Text -> Text -> Button Source

Take the button title and the button payload (this data will be sent back to you via webhook) and return a "postback" button

recipient :: Maybe Text -> Maybe Text -> Maybe Recipient Source

Take reciptient id (optional) or phone_number (optional) and return a 'Maybe Recipient' object. Return Nothing when values are either both (Just _) or both Nothing.

sendButtonTemplateMessageRequest :: Maybe NotificationType -> Recipient -> Text -> [Button] -> SendStructuredMessageRequest Source

Take a notification type (optional), a recipient, the text of the message and a list of buttons (they will appear as call-to-actions). Return a SendStructuredMessageRequest for a structured message with button template

sendGenericTemplateMessageRequest :: Maybe NotificationType -> Recipient -> [BubbleElement] -> SendStructuredMessageRequest Source

Take a notification type (optional), a recipient, a list of ButtonElement. Return a SendStructuredMessageRequest for a structured message with generic template

sendImageMessageRequest :: Maybe NotificationType -> Recipient -> Text -> SendStructuredMessageRequest Source

Take a notification type (optional), a recipient, an image url. Return a SendStructuredMessageRequest for a structured message with image attachment

sendReceiptTemplateMessageRequest :: Maybe NotificationType -> Recipient -> Text -> Text -> Text -> Text -> Maybe Text -> Maybe Text -> [ReceiptItem] -> Maybe ShippingAddress -> PaymentSummary -> Maybe [PaymentAdjustment] -> SendStructuredMessageRequest Source

Take a notification type (optional), a recipient and all the informations needed to construct a ReceiptTemplate object. Namely: the recipient name, the order number (must be unique), the currency, the payment method, the timestamp (optional), the order url (optional), a list with the receipt items, the shipping address (optional), the payment summary and, finally, a list of payment adjustments (optional). Return a SendStructuredMessageRequest for a structured message with receipt template

sendTextMessageRequest :: Maybe NotificationType -> Recipient -> Text -> SendTextMessageRequest Source

Take a notification type (optional), a recipient and a text. Return a SendTextMessageRequest. Raise an error if the text is longer than 320 characters.

setWelcomeButtonTemplateMessageRequest :: Text -> [Button] -> WelcomeMessageRequest Source

Take the text of the message and a list of buttons (they will appear as call-to-actions). Return a WelcomeMessageRequest for a structured message with button template

setWelcomeGenericTemplateMessageRequest :: [BubbleElement] -> WelcomeMessageRequest Source

Take a list of ButtonElement. Return a WelcomeMessageRequest for a structured message with generic template

setWelcomeImageMessageRequest :: Text -> WelcomeMessageRequest Source

Take an image url. Return a WelcomeMessageRequest for a structured message with image attachment

setWelcomeTextMessageRequest :: Text -> WelcomeMessageRequest Source

Take a text. Return a WelcomeMessageRequest

uploadImageMessageRequest :: Recipient -> FileUpload -> UploadImageMessageRequest FileUpload Source

Take a Recipient and FileUpload (relative to a jpg or png). Return a ('UploadImageMessageRequest FileUpload') for a structured message contatining and image uploaded using multipart form data.

webUrlButton :: Text -> Text -> Button Source

Take the button title and the button url (this URL is opened in a mobile browser when the button is tapped) and return a "web_url" button