Skip to content

Meta Messaging Overview

The Meta messaging module adds Instagram DM and Facebook Messenger as messaging channels. Both channels share a single OAuth connection, webhook endpoint, and Graph API client through a unified Meta platform foundation.

  • OAuth connection flow — Connect a Facebook Page (and linked Instagram Business account) via Settings → Integrations
  • Unified webhook — Single endpoint handles events from both Messenger and Instagram DM
  • Inbound messages — Automatic contact resolution, profile enrichment, and attachment processing
  • Outbound messages — Send text and attachments through the compose bar
  • Delivery/read receipts — Watermark-based status tracking from Meta
src/mods/meta/
├── api/
│ ├── meta_connection_api.rs # OAuth URL, status, disconnect
│ ├── meta_oauth_callback_api.rs # OAuth callback handler
│ └── meta_webhook_api.rs # Webhook verify + event dispatch
├── conf/
│ └── meta_messaging_core_conf.rs # App credentials from core_conf
├── services/
│ ├── meta_graph_service.rs # Graph API HTTP client
│ ├── meta_send_service.rs # Send messages via Graph API
│ └── meta_token_service.rs # Token exchange + pending cache
└── types/
├── meta_connection_types.rs # Connection status, OAuth state
└── meta_webhook_types.rs # Webhook payload types

Four migrations create the Meta schema:

TablePurpose
organization_meta_settingsStores page access token, Page ID, IG account ID per org
contact_facebookMaps contacts to Facebook PSIDs
contact_instagramMaps contacts to Instagram IGSIDs
core_conf (extended)Adds meta_messaging_app_id, meta_messaging_app_secret, meta_messaging_verify_token

Two new variants added to MessageChannel in message_channel_type.rs:

pub enum MessageChannel {
// ... existing variants
FacebookMessenger,
InstagramDm,
}

Both channels appear in the compose bar, conversation feed filters, and dashboard charts.

Set these values in Admin → System Config before connecting:

FieldDescription
meta_messaging_app_idFacebook App ID from Meta Developer Portal
meta_messaging_app_secretFacebook App Secret — used for token exchange and webhook signature verification
meta_messaging_verify_tokenCustom string for webhook hub verification

No environment variables are required — all configuration is database-backed.