Facebook Messenger Integration Guide
This guide will help you integrate your Mica AI assistant with Facebook Messenger, enabling your AI assistant to interact with users through Facebook.
Prerequisites
Before starting the configuration, please ensure you have:
- Facebook Developer Account (register at Facebook Developer Platform)
- Facebook Business Page - This will serve as the interface for your AI assistant to interact with users
Configuration Process
1. Create Facebook Application
- Open Facebook Developer Platform
- Click “Create App” and select “Messaging” as the app type
- After creation, find the “Messenger” configuration option in the left menu
2. Set up Messenger
- In the Messenger configuration page, select and link your Facebook Business Page
- Click “Generate Token” to get the Page Access Token
- Configure Webhook
- Set callback URL (Webhook URL):
https://{your-Mica-server-domain}/v1/facebook/webhook/{bot_name}
For example: If your domain is
mica-labs.github.io
and your bot name ismica
, then the callback URL should be:https://mica-labs.github.io/v1/facebook/webhook/mica
- Set verification token: Create a secure verification token (this token must be consistent in both Facebook and Mica configurations)
- Select subscription events: Must check
messages
andmessaging_postbacks
- Set callback URL (Webhook URL):
3. Configure Mica
Add the following configuration to your Mica configuration file:
bot_name: mica # Your bot name
llm_config:
headers:
Authorization: Bearer xxx # Your authorization token
facebook:
verify_token: {your-verification-token} # Must match the verification token in Webhook settings
page_access_token: {page-access-token} # Page Access Token obtained from Facebook Developer Platform
secret: {your-app-secret} # Your Facebook application secret
Testing Steps
After completing the configuration, follow these steps to verify if the integration is successful:
- Visit your configured Facebook Business Page
- Find and click the “Send Message” button on the page
- Send a test message in the dialog box
- Observe if the AI assistant responds correctly to your message
Common Issues and Solutions
Unable to Send Messages
- Check if the Page Access Token has expired or is incorrectly entered
- Verify if the Webhook URL is properly configured and accessible
- Confirm that your server supports HTTPS (Facebook requirement)
Webhook Verification Failed
- Carefully verify that the verification token matches exactly on both ends
- Ensure your callback URL is accessible and responds in the correct format
- Check if the Webhook subscription events are correctly selected
Message Response Delays
- Check if the server network connection is stable
- Review Mica’s running status and logs
- Verify Facebook server status