からの応答で応答するために私のFacebookのメッセンジャーボットを取得できません。私はそれに書き込むときは、スラックとFacebook Messengerの両方のためにApi.Aiで設定した応答で答えますが、Api.Aiは私のサービスへの呼び出しを行う履行部分に、それはスラックで正常に動作しますが、私は取得しますFacebook Messengerからの応答はありません。は、私がApi.Aiボットを作り、スラックやFacebook Messengerの両方でそれを統合している私のサービス
私は私のサービスから返すメッセージのフォーマット:
{
"contextOut": [
{
"lifespan": 2,
"name": "weather",
"parameters": {
"city": "Rome"
}
}
],
"data": {
"facebook": {
"message": {
"text": "Great success!"
},
"recipient": {
"id": "1454102654663349"
}
},
"slack": {
"attachments": [
{
"color": "#00A399",
"title": "Hello world!",
"title_link": "https://www.mywebsite.se"
}
],
"text": "Horray! Great success! :)"
}
},
"displayText": "Whatever!!",
"followupEvent": {
"followupEvent": {
"data": {
"parameter": "<parameter_value>"
},
"name": "<event_name>"
}
},
"source": "mywebsite.se",
"speech": "Whatever!?"
}
Facebookの受信者IDが私のサービスに対して行ったリクエストから来ています。
request.result.contexts[0].parameters.Facebook_sender_id
私はFacebookアプリの製品設定タブでウェブフックを確認しました。
ページアクセストークンを使用してページに自分のアプリを登録しました。
私はウェブフックの下に以下のイベントがチェックしている:メッセージ、messaging_postbacks
のFacebookにボットをしようとしたとき、私は、アプリの管理者ユーザーとしてログインしています。
私はアイデアの出だけど、私が見逃している何かがなければなりませんか?
編集:私はテスト目的のための私のウェブフックとしてAzureの機能を設定して 。
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
var request = await req.Content.ReadAsAsync<ApiAiMessage>();
log.Info($"Incoming: {JsonConvert.SerializeObject(request)}");
var slack_message = new {
text = $"Horray! Great success! :)",
attachments = new[] {
new {
title = "Hello world!",
title_link = "https://www.mywebsite.se",
color = "#00A399"
}
}
};
var facebook_message = new {
recipient = new {
id = $"{request.result.contexts[0].parameters.Facebook_sender_id}"
},
message = new {
text = "Great success!"
}
};
var response = new
{
data = new
{
facebook = facebook_message,
slack = slack_message
},
speech = "Whatever!?",
displayText = "Whatever!!",
contextOut = new[] {
new {
name = "weather",
lifespan = 2,
parameters = new {
city = "Rome"
}
}
},
source = "mywebsite.se",
followupEvent = new {
followupEvent = new {
name = "<event_name>",
data = new {
parameter = "<parameter_value>"
}
}
}
};
log.Info($"Outgoing: {JsonConvert.SerializeObject(response)}");
return req.CreateResponse(HttpStatusCode.OK, response, new MediaTypeHeaderValue("application/json"));
}
どのようにあなたが実際にAPI.ai応答でのFacebookへの要求を行っているように見えるのか?上記のコードは、FBに応答を送信するために貼り付けられていないコードを使用していることが問題であり、それがブレークが発生している場所であれば、問題の診断に役立ちません。 また、郵便配達でテストしましたか?あなたは正しいFBページトークンとパラメータでリクエストを送信していますか? –
郵便配達員とのリクエストの送信はうまく動作し、スラックと同じ動作をします。 Botは私の質問に貼り付けられた応答を返します。私は自分のサービスで発信メッセージを記録し、Facebook Messengerからの要求を送信するときに応答が同じであることを確認できます。唯一の違いはFacebookの受信者IDであることは明らかにFacebook以外のソースからのリクエストを行うときには存在しません。 私が使用しているAzure関数で質問を編集しました。 – mrapan
FBトークンをどこにメッセンジャーに送っていますか? –