Skip to main content

Crate ferro_whatsapp

Crate ferro_whatsapp 

Source
Expand description

§ferro-whatsapp

WhatsApp Business Cloud API integration for the Ferro framework.

Provides outbound message sending (text and template messages) via the Meta Cloud API v23.0, with a static OnceLock facade matching the ferro-stripe pattern. Inbound webhook verification, message deduplication, and typed event dispatch are provided by the webhook and dedup modules.

§Quick Start

use ferro_whatsapp::{WhatsApp, WhatsAppConfig, Message};

// Initialize once at app startup
let config = WhatsAppConfig::from_env(Box::new(|phone| phone == "393401234567"))
    .expect("WhatsApp config not set");
WhatsApp::init(config);

// Send a text message from any handler
let result = WhatsApp::send("393409999999", Message::Text {
    body: "Your order is ready!".into(),
}).await?;
println!("Sent wamid: {}", result.wamid);

Re-exports§

pub use client::WhatsApp;
pub use config::WhatsAppConfig;
pub use dedup::DeduplicationStore;
pub use dedup::InMemoryDeduplicationStore;
pub use error::Error;
pub use message::DeliveryStatus;
pub use message::Message;
pub use message::SendResult;
pub use message::SenderIdentity;
pub use webhook::events::ProcessWhatsAppWebhook;
pub use webhook::events::WhatsAppStatusUpdate;
pub use webhook::events::WhatsAppTextReceived;
pub use webhook::signed_whatsapp_payload;
pub use webhook::verify_whatsapp_webhook;

Modules§

client
config
dedup
error
message
webhook