Skip to content

Profile API

Romain Monteil edited this page Jan 11, 2018 · 2 revisions

Profile API

This API allow you to configure your messenger's bot

Adding properties

$persistentMenus = [
    PersistentMenu::create()
        ->setComposerInputDisabled(true)
        ->addButtons([
            Nested::create('My Account', [
                Postback::create('Pay Bill', 'PAYBILL_PAYLOAD'),
                Postback::create('History', 'HISTORY_PAYLOAD'),
                Postback::create('Contact Info', 'CONTACT_INFO_PAYLOAD'),
            ]),
            WebUrl::create('Latest News', 'http://petershats.parseapp.com/hat-news')
                ->setWebviewHeightRatio('full')
        ]),
    PersistentMenu::create('zh_CN')
];

$greetings = [
    Greeting::create('Hello!'),
    Greeting::create('Timeless apparel for the masses.', 'en_US'),
]);

$paymentSettings = PaymentSettings::create()
    ->setPrivacyUrl('http://www.facebook.com')
    ->setPublicKey('YOUR_PUBLIC_KEY')
    ->addTestUser(12345678);

$targetAudience = TargetAudience::create('custom', ['US'], ['FR'])
    ->addWhitelistCountry('CA')
    ->addBlacklistCountry('IT');

$profileSettings = ProfileSettings::create()
    ->addPersistentMenus($persistentMenus)
    ->addStartButton('GET_STARTED_PAYLOAD')
    ->addGreetings($greetings)
    ->addWhitelistedDomains(['https://petersfancyapparel.com'])
    ->addAccountLinkingUrl('https://www.example.com/oauth?response_type=code&client_id=1234567890&scope=basic')
    ->addPaymentSettings($paymentSettings)
    ->addTargetAudience($targetAudience);

$messenger->profile()->add($profileSettings);

Getting properties

$messenger->profile()->get(['persistent_menu', 'greeting', 'get_started']);

Deleting properties

$messenger->profile()->delete(['persistent_menu', 'greeting', 'get_started']);
Clone this wiki locally