•   over 5 years ago

About Facebook graph api

How would i implement it to fetch user's first name from Facebook to greet!? in node js.

PS: i couldn't understand how to implement below doc in my node js.

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

  • 12 comments

  •   •   over 5 years ago

    The Greeting Text supports the 4 template variables listed in the docs. There's an example on the end of the page you linked (Hello {{user_first_name}}!)

  •   •   over 5 years ago

    I understand lars but since I'm using node js i don't know how to set {{user_first_name}}! In my index.js

    And there's no documentation for node js in there. Example is in json so?

  •   •   over 5 years ago

    Greeting Text is part of the Profile API properties that are explained here: https://developers.facebook.com/docs/messenger-platform/reference/messenger-profile-api

    See "Set/Update Properties" on that docs page, this explains how to set the available properties/values.

  •   •   over 5 years ago

    So you mean i have to do curl command in console? And in my custom greeting messege which is "Hello {{user_first_name}}!" i have to leave as it is? Please explain bit programmatically because i'm stucked at custom greeting from two days.

  •   •   over 5 years ago

    Curl example call is also in the docs in the "Set/Update Properties" section?

  •   •   over 5 years ago

    Yes, There's curl example but i still don't know is how this can be implemented!

  •   •   over 5 years ago

    You'd update the example call to match the property you want to set ...

    curl -X POST -H "Content-Type: application/json" -d '{
    "greeting":[
    {
    "locale":"default",
    "text":"Hello!"
    }, {
    "locale":"en_US",
    "text":"Timeless apparel for the masses."
    }
    ]
    }' "https://graph.facebook.com/v8.0/me/messenger_profile?access_token="

  •   •   over 5 years ago

    Also i should add my access token after access_token= and if this is step then after this curl step what i have to in my index.js? Where i had set up Welcome intent and Custom greeting response so what to edit in there too?

  •   •   over 5 years ago

    Yes, you need to add your page access token. Also this is a one-time setup/config call/request only so you probably don't need to have a respective route/index.js for it.

  •   •   over 5 years ago

    Last question, so i shouldn't need to send the " curl -i - X Get....." req???
    Also thank you so much this means a lot.

  •   •   over 5 years ago

    Messenger Profile settings most likely only need to be set once, it's like a config for your Messenger Profile/bot/app. You can make a request via Curl (or any other lib/tool) to set any of the available properties.

  •   •   over 5 years ago

    Thank you sir! Much respect to support :)

Comments are closed.