App Events help you understand and track key events that take place in your Messenger experience. The Messenger Platform logs these automatically for several activities, but you can also manually log custom events from your bot using Graph API calls.
Before you can begin, you'll need to register your bot with Meta. See our Messenger Platform Quick Start Guide to learn more.
App event logging is automatic when your Bots for Messenger app interacts with a user. To create your own events to log interactions or events that are not logged automatically, see the Logging Custom Events section.
The events in this table are logged automatically by the Messenger Platform.
| Event Name | Description |
|---|---|
| The bot has received a message. Message Received Event Parameters:
|
| The bot has sent a message. Message Sent Event Parameters:
|
| The user has interacted with an element that initiated a postback, such as a call to action (CTA) button, persistent menu, or structured message. Postback Called Event Parameters:
|
| The bot was unblocked by the user. |
| The bot was blocked by the user. |
| A message thread was deleted by the user. |
In addition to the predefined events, bots can log custom events by using the Application Activities Graph API endpoint.
The following table describes the properties and values that must be provided to the endpoint to log a custom bot event.
| Property | Description | Value |
|---|---|---|
| Specifies the event type. | Use |
| Specifies the custom event details. | Use a JSON-encoded array to specify your custom event details. |
| Specifies whether advertising tracking is enabled on iOS 14.5+ devices. | Use |
| Specifies whether advertising tracking is enabled at the application level. | Use |
| Specifies the event source. | Use a JSON-encoded array with a single value of |
| Specifies the page ID associated with the messenger bot that logs the event. | Use the Facebook page ID of the page associated with the bot. |
| Specifies the page-scoped user ID associated with the messenger bot that logs the event. | Use the page-scoped user ID provided to your webhook. |
The following example demonstrates how to log a purchase event.
curl -X POST \
"https://graph.facebook.com/<APP_ID>/activities" \
-F 'event=CUSTOM_APP_EVENTS' \
-F 'custom_events=[{"_eventName":"fb_mobile_purchase","_valueToSum":55.22,"fb_currency":"USD"}]' \
-F 'advertiser_tracking_enabled=1' \
-F 'application_tracking_enabled=1' \
-F 'extinfo=["mb1"]' \
-F 'page_id=<PAGE_ID>' \
-F 'page_scoped_user_id=<PSID>'On success, your app will receive the following response:
{"success": true}The following example demonstrates how to log a lead event.
curl -X POST \
"https://graph.facebook.com/<APP_ID>/activities" \
-F 'event=CUSTOM_APP_EVENTS' \
-F 'custom_events=[{"_eventName":"lead_submitted"}]' \
-F 'advertiser_tracking_enabled=1' \
-F 'application_tracking_enabled=1' \
-F 'extinfo=["mb1"]' \
-F 'page_id=<PAGE_ID>' \
-F 'page_scoped_user_id=<PSID>'On success, your app will receive the following response:
{"success": true}