2017-01-23 10 views
0

私は最初のメッセンジャーボットをjsに構築しています。すでにメッセージを受信して​​返信したり、オプションでカードを送信したりできますが、 ...これは私がそれをしたものです:Facebookのメッセンジャーボット開始ボタン

私は間違っているか、どこでfacebookthreadAPI関数を呼び出さなければならないのか分かりません。アドバイスが必要です。 index.jsから

抜粋:FB-GET-開始-button.jsonから

function facebookThreadAPI(jsonFile, cmd){ 
// Start the request 
request({ 
    url: 'https://graph.facebook.com/v2.6/me/thread_settings?access_token='+process.env.token, 
    method: 'POST', 
    headers: {'Content-Type': 'application/json'}, 
    form: require(jsonFile) 
}, 
function (error, response, body) { 
    if (!error && response.statusCode == 200) { 
     // Print out the response body 
     console.log(cmd+": Updated."); 
     console.log(body); 
    } else { 
     // TODO: Handle errors 
     console.log(cmd+": Failed. Need to handle errors."); 
     console.log(body); 
    } 
});} 

を抜粋:

{ 
    "setting_type":"call_to_actions", 
    "thread_state":"new_thread", 
    "call_to_actions":[ 
     { 
     "payload":"action?POSTBACKHERE" 
     } 
    ] 
} 

答えて

1

Facebookは、グリーティングテキストや永続メニューなどの他の多くの機能を備えた開始ボタンを設定するための新しいAPIを提供しています。古いthread_setting APIではなくメッセンジャープロファイルカール

curl -X POST -H "Content-Type: application/json" -d '{ 
     "get_started":{ 
     "payload":"GET_STARTED_PAYLOAD" 
    } 
    }' "https://graph.facebook.com/v2.6/me/messenger_profileaccess_token=PAGE_ACCESS_TOKEN"  

を使用した例.FOR APIは、あなたが望む任意のペイロードを持つトークンとGET_STARTED_PAYLOADあなたのページにアクセスしてPAGE_ACCESS_TOKENを交換してください。 その新しいAPIで、私はその要求にGetStartedボタンを設定しようとしている、今、完全tutorial here

0

私は同じ問題を抱えています。 Hereを参照してください。

私は結果のない例を実行しようとしました。

カール-X POST -H "コンテンツタイプ:アプリケーション/ JSON" -d「{ "setting_type": "call_to_actions"、 "thread_state": "new_thread"、 "call_to_actions":[ { "ペイロード": "USER_DEFINED_PAYLOAD" }] }」 "https://graph.facebook.com/v2.6/me/thread_settings?access_token=PAGE_ACCESS_TOKEN"

私のエラーは、次のとおり

オブジェクトを管理するためにpages_messaging権限が必要です

私のページは公開されていません。

編集:ソリューションHereを見つけることができます。ページ管理者では機能しません

0

を参照してください:curl -X POST -H "Content-Type: application/json" -d '{ "get_started":{ "payload":"start"} }' "https://graph.facebook.com/v2.6/me/messenger_profile?access_token=My_Token"{"result":"success"}を得ます。しかし、そのボタンはまだチャットに表示されません。だから、私はまだ理解していない、ここで何が問題なのか...

関連する問題