Search code examples
facebook-messengerchatbotdialogflow-esfacebook-chatbot

Facebook Messenger bot: 1st interaction different to subsequent for same command?


Does anyone know if it's possible to return a different message etc to the chat user if it's the very first time they are interacting with the bot?

For instance, if a user says "hello" (or anything) for the very first time, the bot might respond with, "Hello there!"

If a user says hello some time later, the bot might respond with "Hello, again!"

Looking through the developer docs I'm struggling to find an answer: https://developers.facebook.com/docs/messenger-platform

For context, I'm also using the https://api.ai service.


Solution

  • One way to accomplish this is to set up a "get started" button:

    https://developers.facebook.com/docs/messenger-platform/messenger-profile/get-started-button

    This might also be helpful:

    https://developers.facebook.com/docs/messenger-platform/messenger-profile/greeting-text

    (But I haven't used it myself, so I'm not sure what it does.)

    Also, as already mentioned, you can store user data in your own database, and send a greeting message if you can't find the user there already.