Russenger - Facebook Messenger Webhook Handling in Rust

Russenger is a Rust library designed to simplify the handling of Facebook Messenger webhook responses. It offers a convenient way to construct and send various types of responses, including text messages, quick replies, generic templates, and media attachments.
Features
Russenger provides the following features:
- Text messages: Send text messages to users.
- Quick replies: Send quick replies with buttons to users.
- Generic templates: Send generic templates with images, titles, and buttons to users.
- Media attachments: Send media attachments such as images, audio, and video to users.
- Webhook verification: Verify incoming webhook requests from Facebook.
Installation
Install generate first if it's not yet installed
Create project with template
How To Use
Project
Example
Here's an example of how to use Russenger to handle different actions in a chatbot:
Russenger Cargo.toml
= { = "https://github.com/j03-dev/russenger", = "main" }
= "0.5"
Environnement .env
# You can change this
PORT=6969
HOST=0.0.0.0
# change this
VERIFY_TOKEN=<your-verify-token>
# change this
PAGE_ACCESS_TOKEN=<your-page-access-token>
#### postgres
# DATABASE=postgres://<user>:<password>@<host>/<db_name>
#### mysql
# DATABASE=mysql://<user>:<password>@<host>/<db_name>
#### sqlite
DATABASE=sqlite:<db_name>
Code src/main.rs
use *;
create_action!;
create_action!;
create_action!;
russenger_app!;
Run
Migrate Database run it once
if you use sqlite as Bb
Runserver
In this example, we define three actions: Main, Option1, and Option2. Each action is associated with a function that handles the action. The Main action sends a text message and a quick reply with two options. The Option1 and Option2 actions handle the user's selection of the respective options.
EndPoint
-
GET
/webhook: Verify your chatbot with Facebook Messenger. Facebook will send a challenge, and your bot must respond correctly for verification. -
POST
/webhook: This is where Facebook Messenger sends messages from users. Handle incoming messages and respond accordingly here.