user3776662
user3776662

Reputation: 199

How to have a Facebook messenger Bot send updates to a user

I want to have a bot send a message to every user without having to engage in a conversation with it directly. For example, have a bot send a message saying "happy friday!" if its a friday. This message would be automatically sent to every user currently engaged with the user.

Upvotes: 1

Views: 992

Answers (1)

jonas
jonas

Reputation: 125

When the user interacts with you (e.g. CTA-Button, first message) save the user id in a database.

Example for php and a CTA

if(isset($message['postback']) && $message['postback']['payload'] == 'USER_DEFINED_PAYLOAD_SUBSCRIBE'){

    $query = 'INSERT INTO facebook (facebook_id) VALUES (\'' . $message['sender']['id'] . '\')';
    $bot->send(new Message($message['sender']['id'], 'Subscribed'));

}

If you want broadcast your updates, trigger a script that sends a message to each facebook id (from database).

As far as i know there is no broadcast function (like WhatsApp has).

Upvotes: 1

Related Questions