フェイスブック
3192 ワード
まずはFBアカウントでログインしてログインしてください
ngrok zipファイルもインストールします

指示に従って記入してください


それは今、私たちはいくつかのコードを行う
フォルダを作成し、これらのモジュールをインストールする
FBBOTパイ
ページアクセストークンと
ここでngrokを抽出し、ワークスペースに貼り付けます

fbbotを実行する.パイ
管理者としてのNgrok
このCMDを入れる
ヒットエンター
ここからHttpsを終了します.io
そして、それをここでトークン名で保存してください

あなたのアプリケーションを再構築し、再起動するには良いです
ngrok zipファイルもインストールします
https://developers.facebook.com/
https://ngrok.com/download

指示に従って記入してください


それは今、私たちはいくつかのコードを行う
フォルダを作成し、これらのモジュールをインストールする
pip install pymessenger
pip install requests
pip install flask
フォルダを開き、ファイル名を作成するFBBOTパイ
from flask import Flask,request
import requests
from pymessenger import Bot
app = Flask(__name__)
VERIFY_TOKEN = ''
PAGE_ACCESS_TOKEN =''
bot = Bot(PAGE_ACCESS_TOKEN)
def handling_message(text):
adjusted_msg = text
if adjusted_msg == 'hi' or adjusted_msg == 'Hi':
response = 'hey'
elif adjusted_msg == "what's up" or adjusted_msg == "what's up":
response = "i'm Great"
else:
response = "it's pleasure to talk with you,Thank you."
return response
@app.route('/', methods = ["POST","GET"])
def web_hook():
if request.method == "GET":
if request.args.get('hub.verify.token') == VERIFY_TOKEN:
return request.args.get('hub.challenge')
else:
return 'Unable To Connect Meta'
elif request.method == 'POST':
data = request.json
process = data['entry'][0]['messaging']
for msg in process:
text = msg['message']['text']
sender_id = msg['sender']['id']
response = handling_message(text)
bot.send_text_message(sender_id,response)
return 'Message Delivered'
else:

if __name__ == '__main__':
app.run()
証明トークンについて何か名前ページアクセストークンと
ここでngrokを抽出し、ワークスペースに貼り付けます

fbbotを実行する.パイ
管理者としてのNgrok
このCMDを入れる
ヒットエンター
ngrok.exe http 5000
今、あなたはそれに接続されてここからHttpsを終了します.io
そして、それをここでトークン名で保存してください

あなたのアプリケーションを再構築し、再起動するには良いです
Reference
この問題について(フェイスブック), 我々は、より多くの情報をここで見つけました https://dev.to/nothanii/facebook-chatbot-using-flask-4fhdテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol