Search code examples
facebookchatfacebook-messengerfacebook-messenger-bot

Send message to user in facebook customer chat plugin as soon as logged in


I'm trying to send a message to the user as soon as they click on the chat button on my Customer Chat Plugin, what I want to achieve is exactly the flow from this website: mobile monkey

The flow is:

  • User enters page and click log into messenger
  • chat window opens with message

I can't find any example on how to send the user this message without the user sending a message first. To send a message I need the PSID for the user in my php service, but I can't get any response on the user login.

Also, is there any way I can get that PSID on my frontend? What I'm developing requires the bot to ask questions when there is some user action on my website.

edit: Just to be clear, it is not the greeting message, it is and actual message when the chat window opens, see ref.

enter image description here


Solution

  • Ended up finding the answer, just had to use a postback webhook.

    More info here : https://developers.facebook.com/docs/messenger-platform/reference/webhook-events/messaging_postbacks