/fb-messenger-clj

A Clojure Library for the Facebook Messenger Bot API. Wiki: https://github.com/prometheus-ai/fb-messenger-clj/wiki

Primary LanguageClojureMIT LicenseMIT

Introduction to fb-messenger-clj

fb-messenger-clj is a Clojure library for the Facebook Messenger Bot API.

The goal of this library is to provide easy-to-use functions, well defined documentation & application examples so you can start with development and get results right away.

Installation

fb-messenger is available as a Maven artifact from Clojars.

With Leiningen/Boot:

Clojars Project

Quickstart

The Facebook Messenger Library is provided by the fb-messenger namespace.

First, require the namespace needed (for example auth) in the REPL:

(require '[fb-messenger.auth :as fb])

Or in your application:

(ns my-app.core
  (:require [fb-messenger.auth :as fb]))

Documentation & Code Examples

See how to set up a Facebook Messenger Bot in the Wiki.

Code examples:

Further Code Examples in Clojure:

About the library

This library has the following functions:

Authentication (auth.clj)

(authenticate params)

Sending Messages (send.clj)

Send messages to users. (Send Message API Facebook Documentation)

Send Message Handler:

(send-message recipient-id message)

Examples using the text and video message templates from below:

(send-message recipient-id (text-message "Hello World"))
(send-message recipient-id (video-message [video-url]))

Available Message Templates (templates.clj)

Image:

(image-message [image-url])

Video:

(video-message [video-url])

Audio:

(audio-message [audio-url])

File:

(file-message [file-url])

Text:

(text-message [text])

Quick Replies:

(quick-replies-message [text quick-replies])

Button Template:

(button-template [text buttons])

Generic Template:

(generic-template [elements])

URL Button:

(url-button [title url])

Postback Button:

(postback-button [title postback])

Quick Reply Template:

(quick-reply [title payload *image-url*])

Location Quick Reply:

(location-quick-reply)

Upload File Attachment

You can send files by uploading them. (File Attachment Facebook Documentation)

(upload-attachment type url)

Set Facebook Messenger Profile:

Set your Bot's properties via the Facebook Messenger Profile API.

e.g. Persistent Menu, Get Started Button, Greeting Text, Domain Whitelisting, Account Linking, Payment Settings, Target Audience

(set-messenger-profile profile)
(get-user-profile psid)

Register for a Facebook Page Access Token

To start using the Facebook Messenger Send/Receive service you'll need to setup a Facebook Page, Facebook App, create a Page Access Token and link the app to the page. We'll run through this step by step here.

Contributing

  1. Use parinfer.
  2. Follow the Clojure Style Guide.

License

The use and distribution terms for this software are covered by the MIT License. You must not remove this notice, or any other, from this software.

Disclaimer: This software is not affiliated to Facebook or represents Facebook in any way.