-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprofile.js
66 lines (61 loc) · 1.46 KB
/
profile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
* Messenger Profile settings.
*
* This module sends basic bot configuration like the greeting message
* and the persistent menu to Facebook using the Messenger Profile API.
*
* Not loaded with the app - use `npm run-script update-profile`.
*/
'use strict';
const sendApi = require( './helpers/send' );
const script = require( './helpers/script' );
const axios = require( 'axios' );
const messengerProfileParams = {
'access_token': process.env.PAGE_ACCESS_TOKEN,
'greeting': [ {
'locale': 'default',
'text': script.greeting
} ],
'get_started': {
'payload': 'get_started'
},
'persistent_menu': [ {
'locale': 'default',
'composer_input_disabled': false,
'call_to_actions': [
{
'title': script.menu.tag,
'type': 'postback',
'payload': 'menu.tag'
},
{
'title': script.menu.ask,
'type': 'postback',
'payload': 'menu.ask'
},
{
'title': script.menu.submenu,
'type': 'nested',
'call_to_actions': [
{
'title': script.menu.facts,
'type': 'postback',
'payload': 'menu.facts'
},
{
'title': script.menu.photos,
'type': 'postback',
'payload': 'menu.photos'
}
]
}
]
} ]
}
axios.post( 'https://graph.facebook.com/v2.6/me/messenger_profile', messengerProfileParams )
.then( function( res ) {
console.log( 'Updated messenger_profile' );
} )
.catch( function( err ) {
console.error( 'Unable to update messenger_profile', err );
} );