0

私はうまく動作するFacebook Messengerボットを作成しました。私はButton TemplateとImageテンプレートを使いましたが、どちらも完璧に動作します。しかし、私がGeneric Templateを試しても、私は何の反応も得ません。適切な変更を行って、hereのコードを貼り付けてコピーしました。Facebook Messenger bot一般的なテンプレートが動作しない

デバッグ方法がわかりません。 Facebookのメッセンジャーは、メッセージングボックスに出力しません。私は現在、Heroku経由でアプリを実行しています。

def send_message(token, recipient): 
    r = requests.post("https://graph.facebook.com/v2.6/me/messages", 
    params={"access_token": token}, 
    data=json.dumps({ 
     "recipient":{ 
     "id":recipient 
     }, 
     "message":{ 
     "attachment":{ 
      "type":"template", 
      "payload":{ 
      "template_type":"generic", 
      "elements":[ 
       { 
       "title":"Welcome to Peter\'s Hats", 
       "image_url":"http://www.godominion.com/content/images/feature-img-small-appliance-electronics.png", 
       "subtitle":"We\'ve got the right hat for everyone.", 
       "default_action": { 
        "type": "web_url", 
        "url": "https://peterssendreceiveapp.ngrok.io/view?item=103", 
        "messenger_extensions": true, 
        "webview_height_ratio": "tall", 
        "fallback_url": "https://peterssendreceiveapp.ngrok.io/" 
       }, 
       "buttons":[ 
        { 
        "type":"web_url", 
        "url":"https://petersfancybrownhats.com", 
        "title":"View Website" 
        }   
       ]  
       } 
      ] 
      } 
     } 
     } 
    }), 
    headers={'Content-type': 'application/json'}) 
    if r.status_code != requests.codes.ok: 
     print r.text 

私は任意の助けをいただければ幸いです。

は、ここに私のコードです。

ありがとうございます。

EDIT 1:SOLUTION私はコメントアウトすることで、問題を処分した

"messenger_extensions": true,

"fallback_url": "https://peterssendreceiveapp.ngrok.io/"},

が、私はこれがないと確信しています正しい方法。しかし、実際のリンクのないボットを作っているので、これはうまくいきます。

+0

すべてのリンクが正常に動作していることを確認してください –

答えて

関連する問題