Integrate ChatBotKit with Facebook Messenger to deploy AI bots that engage customers directly in their preferred messaging app.

The Messenger integration lets you deploy your ChatBotKit AI bot to Facebook Messenger, allowing customers to message your Page directly. Users can start conversations with your bot, and it responds using the knowledge and instructions you have configured. All conversations maintain context across messages, creating natural, coherent interactions.

What You Can Do

With the Messenger integration, you can:

  • Direct Messaging: Deploy the bot to handle private messages sent to your Facebook Page
  • Conversation Context: Maintain conversation state so replies reference previous messages in the thread
  • Contact Collection: Automatically capture contact information from users who message your Page
  • Session Management: Configure how long a conversation stays open before starting fresh
  • File Attachments: Process images and media files sent by users (beta feature)
  • Custom Metadata: Attach tracking or integration metadata to your integration
  • Automated Responses: Provide 24/7 customer support through Facebook Messenger without manual intervention

How It Works

When someone sends a private message to your Facebook Page, Messenger forwards it to ChatBotKit through a webhook. Your bot processes the message using its backstory, knowledge (datasets), and capabilities (skillsets), then sends the reply back through Messenger. The bot remembers the conversation history within the session window, allowing for natural follow-up messages.

Getting Started

To set up the Messenger integration:

  1. Go to Integrations: Navigate to Integrations and click Create Integration
  2. Select Messenger: Choose Messenger Bot from the available options
  3. Name and Bot: Give the integration a descriptive name and select which ChatBotKit bot will handle conversations
  4. Create: Click Create to generate your integration
  5. Get Your Webhook URL: After creation, you will see your unique webhook URL in the integration page
  6. Generate Access Token: In Facebook Developer Portal, generate a permanent access token using a System User (required for ChatBotKit to authenticate)
  7. Add Access Token: Paste the access token into the Access Token field in your ChatBotKit integration
  8. Configure Facebook Webhook: In Facebook App Dashboard > Messenger > Settings, add your ChatBotKit webhook URL as the callback URL
  9. Click Setup: Click the Setup button in ChatBotKit to verify the webhook connection
  10. Test: Send a test message to your Page to confirm the bot responds

Access Token Requirements

The Access Token must be a permanent token generated using a System User in your Facebook App. This allows ChatBotKit to authenticate requests on behalf of your app. Follow these steps to generate one:

  1. Go to Facebook Developers
  2. Select your app and navigate to Roles > System Users
  3. Create or select a System User with Admin role
  4. Click Generate Access Token and select your Page from the dropdown
  5. Copy the token and paste it into ChatBotKit

The token is stored encrypted and will not be shown in full after saving.

Advanced Options

These settings appear under Advanced Options after the integration is created:

  • Contact Collection - When enabled, the bot automatically creates or updates a contact record for each user who messages your Page, capturing their name and Facebook ID
  • Session Duration - How long the bot keeps a conversation context open. Messages within this window continue the same conversation; messages after restart a new one. Default is 1 day
  • Attachments (beta) - When enabled, the bot processes images and media files sent by users
  • Meta - Custom key-value metadata for tracking or system integration purposes

Best Practices

Test Before Going Live: Send test messages to your Page through Facebook Messenger and verify the bot responds appropriately. Check for correct tone, helpful information, and proper formatting.

Set Clear Instructions: In your bot's backstory, include guidelines for messaging. Messenger conversations are often brief and mobile-focused, so keep responses concise and clear.

Use Meaningful Session Duration: The default 1-day session works for most cases, but consider adjusting if your use case requires different behavior. Longer durations (days or weeks) are useful for support bots where users may follow up much later.

Monitor Conversations: Regularly check the Conversations section to understand how users are interacting with your bot and identify areas for improvement.

Collect Useful Contact Info: Enable Contact Collection if you want to build a user list for future campaigns or better personalize responses based on known users.

Troubleshooting

Bot Not Responding: Verify that the Access Token is correct and that the webhook URL has been configured in Facebook App Dashboard. Use the Setup button to re-verify the connection.

Token Expired or Invalid: Generate a new permanent access token using a System User and update it in the integration settings.

Messages Not Being Received: Confirm that your bot can receive messages by checking the Conversations section. If no conversations appear, the webhook may not be properly connected.

Session Not Persisting: If conversations are not maintaining context, check the Session Duration setting. A very short duration (like a few minutes) will cause new sessions to start frequently.