mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-19 07:17:14 +00:00
Enable broadcast of Facebook bot messages (#4688)
* enable broadcast of FB bot messages this should go together with PR https://github.com/home-assistant/home-assistant/pull/12459 it enables FB messenger broadcast ability to send messages to all people who interacted with the bot previously and have the chat open. * fixes as per request from reviewer. fixes as per request from reviewer. FB -> Facebook fixed indents. (not sure what 2x for each level was), but I fixed it as per sample above. * Update notify.facebook.markdown * ✏️ Tiny fixes * Update notify.facebook.markdown * Update notify.facebook.markdown * 🚀 Trigger rebuild
This commit is contained in:
parent
04560310f9
commit
649b3c8755
@ -50,7 +50,7 @@ automation:
|
|||||||
- '+919784516314'
|
- '+919784516314'
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also send messages to users that do not have stored their phone number with Facebook, but this requires a bit more work. The Messenger platform uses page specific user IDs instead of a global user ID. You will need to enable a webhook for the "messages" event in Facebook's developer console. Once a user writes a message to a page, that webhook will then receive the user's page specific ID as part of the webhook's payload. Below is a simple PHP script that reacts to the message "get my id" and sends a reply containing the user's ID:
|
You can also send messages to users that do not have stored their phone number on Facebook, but this requires a bit more work. The Messenger platform uses page-specific user IDs instead of a global user ID. You will need to enable a webhook for the "messages" event in Facebook's developer console. Once a user writes a message to a page, that webhook will then receive the user's page specific ID as part of the webhook's payload. Below is a simple PHP script that reacts to the message "get my id" and sends a reply containing the user's ID:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
<?php
|
<?php
|
||||||
@ -96,10 +96,10 @@ if (preg_match('/get my id/', strtolower($message))) {
|
|||||||
```
|
```
|
||||||
|
|
||||||
### {% linkable_title Rich messages %}
|
### {% linkable_title Rich messages %}
|
||||||
You could also send rich messing (cards, buttons, images, videos, etc). [Info](https://developers.facebook.com/docs/messenger-platform/send-api-reference) to which types or messages and how to build them.
|
You could also send rich messing (cards, buttons, images, videos, etc). [Info](https://developers.facebook.com/docs/messenger-platform/send-api-reference) to which types of messages and how to build them.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# Example script with a notification entry with rich message
|
# Example script with a notification entry with a rich message
|
||||||
|
|
||||||
script:
|
script:
|
||||||
test_fb_notification:
|
test_fb_notification:
|
||||||
@ -117,3 +117,21 @@ script:
|
|||||||
title: Blue
|
title: Blue
|
||||||
payload: DEVELOPER_DEFINED_PAYLOAD_FOR_PICKING_BLUE
|
payload: DEVELOPER_DEFINED_PAYLOAD_FOR_PICKING_BLUE
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You can now also use Facebook public beta broadcast API to push messages to ALL users who interacted with your chatbot on your page, without having to collect their number. This will scale to thousands of users. Facebook requires that this only be used for non-commercial purposes and they validate every message you send. Also note, your Facebook bot needs to be authorized for "page_subscritions" if you want to make it to all but can be used right away to a selected group of testers of your choice.
|
||||||
|
|
||||||
|
To enable broadcast just use the keyword "BROADCAST" as your target. Only put ONE target BROADCAST as below:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- alias: Facebook Broadcast
|
||||||
|
trigger:
|
||||||
|
platform: sun
|
||||||
|
event: sunset
|
||||||
|
action:
|
||||||
|
service: notify.facebook
|
||||||
|
data:
|
||||||
|
message: Some text you want to send
|
||||||
|
target:
|
||||||
|
- BROADCAST
|
||||||
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user