fbsamples / fbsamples/original-coast-clothing

Send fails for Apps without advance User Profile Access

Open
#89 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
231
Forks
239
PR merge metrics
No merged PRs in 30d

Description

Most new apps won't have access to user extra data, so the API call will fail to execute if the api call requests any of these advance unapproved fields.
https://developers.facebook.com/docs/messenger-platform/identity/user-profile/

## Suggestion
Let's include two new env variables that allow developers to setup if advance fields are available for the page and as well as setup their default preferred locale easily.
```
has_extra_user_field_accesss: process.env.HAS_EXTRA_USER_FIELD_ACCESSS || false,
default_locale: process.env.DEFAULT_LOCALE || 'en_US',
```
in https://github.com/fbsamples/original-coast-clothing/blob/master/services/config.js

Then use the above vars like:

```
let fields = 'first_name, last_name';
if (config.has_extra_user_field_accesss) {
fields = 'first_name, last_name, gender, timezone, locale';
}
```
in https://github.com/fbsamples/original-coast-clothing/blob/master/services/graph-api.js#L138

```
if (users[senderPsid].locale != null) {
i18n.setLocale(users[senderPsid].locale);
} else {
i18n.setLocale(config.default_locale);
}
```
https://github.com/fbsamples/original-coast-clothing/blob/master/app.js#L131

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.