LoginSignup
7
2

More than 5 years have passed since last update.

Facebook Messenger PlatformのSend APIで発生したエラーと原因メモ

Last updated at Posted at 2018-09-10

Facebook Messanger PlatformのSend APIを使用したbot作成時、様々なエラーに遭遇したので知見共有のためにメモしておく。

公式リファレンスでエラーコードが載っているドキュメントも存在するが、該当するエラーの記載が無いものもあり原因特定と対応に時間を費やしてしまうことが多い。

エラーコード - Messengerプラットフォーム

とりあえず直近で遭遇したエラーをザッと載せておく。
新しいエラーを観測したら適宜更新予定。

(#-1) Unexpected internal error

message: "https://graph.facebook.com/v2.6/me/messages?access_token=xxxxxxxxxx のリクエストに失敗しました(エラー: 400)。サーバー応答の一部: 
{"error":
{"message":"(#-1) Unexpected internal error",
"type":"OAuthException",
"code":-1,
"error_subcode":2018012,
...

メッセージ送信エラー。
特定ユーザーで発生。直前の送信は成功しており、同時間帯にほぼ同内容のpayload等セットしたユーザーへの送信は問題なし。
詳細原因不明。

(#100) No matching user found

message:  "https://graph.facebook.com/v2.6/me/messages?access_token=xxxxxxxxxx のリクエストに失敗しました(エラー: 400)。サーバー応答の一部: 
{"error":
{"message":"(#100) No matching user found",
"type":"OAuthException",
"code":100,
"error_subcode":2018001,
...
"   

No matching user found (一致する利用者が見つかりませんでした)

メッセージ送信対象のユーザーが見つからなかった場合に出るエラー。
Facebookページ自身のIDに送ったり、存在しないユーザーIDに送ると発生する。

追記:直前までやりとりしてたユーザーで、急にこのエラー発生するケースがあった。
手動でメッセージ送ろうとすると「この人は現在応答できません」と表示されメッセージ送信ができない状態になっていた。
メッセージ受信拒否的な設定変更をされた可能性あり。

(#100) No profile available for this user.

{
 "message": "(#100) No profile available for this user.",
  "type": "OAuthException",
  "code": 100,
  "error_subcode": 2018218,
}

名前等のプロフィール情報取得エラー。電話番号登録のユーザーで発生する模様。

現在、ユーザープロフィールAPIでは、Facebookアカウントではなく電話番号を使用して作成したMessengerアカウントのプロフィール情報を取得できません。

この場合、APIからエラーコード2018218と「No profile available for this user」というメッセージが返されます。

プロフィール情報 - Messengerプラットフォーム

(#100) Param message[text] must be a UTF-8 encoded string

message:  "https://graph.facebook.com/v2.6/me/messages?access_token=xxxxxxxxxx のリクエストに失敗しました(エラー: 400)。サーバー応答の一部: 
{"error":
{"message":"(#100) Param message[text] must be a UTF-8 encoded string",
"type":"OAuthException",
"code":100,
...
"

jsonをそのままmessage.textに入れてFBにポストしてしまうと出る。
基本的に実装上のミスが原因。

(#100) Sender action failed

message: "https://graph.facebook.com/v2.6/me/messages?access_token=xxxxxxxxxx のリクエストに失敗しました(エラー: 400)。サーバー応答の一部: 
{"error":
{"message":"(#100) Sender action failed",
"type":"OAuthException",
"code":100,
"error_subcode":2018048,
...

発生原因不明。一時的なバグ?

(#200) User does not have sufficient administrative permission for this action on this page.

message:"(#200) User does not have sufficient administrative permission for this action on this page. If the page buisness requires Two Factor Authentication, the user also needs to enable Two Factor
...
"

開発環境で発生。
該当するFacebookページの操作に必要な権限が無い。
実行ユーザーがページの管理者アカウントになっていない等が原因。

(#551) This person isn't available right now.

message:  "https://graph.facebook.com/v2.6/me/messages?access_token=xxxxxxxxxx のリクエストに失敗しました(エラー: 400)。サーバー応答の一部: 
{"error":
{"message":"(#551) This person isn't available right now.",
"type":"OAuthException",
"code":551,
"error_subcode":1545041,
...

Message Not Sent: (未送信のメッセージ:)This person isn't available right now. (現在、この利用者はサービスを利用できません)

ユーザーがスレッドをブロックした場合に出る模様。

Facebookアプリが開発者モードになってる場合にも出るらしい。
https://stackoverflow.com/questions/44379656/551-error-with-facebook-messenger-bot-this-person-isnt-available-right-now

(#100) Message cannot be empty, must provide valid attachment or text

message:  "https://graph.facebook.com/v2.6/me/messages?access_token=xxxxxxxxxx のリクエストに失敗しました(エラー: 400)。サーバー応答の一部: 
{"error":
{"message":"(#100) Message cannot be empty, must provide valid attachment or text",
"type":"OAuthException",
"code":100,
"error_subcode": 2018034
...
"   

テキストメッセージを空で送信しようとした。
基本的に開発環境での動作確認中にしか発生しない。

(#10) This message is sent outside of allowed window. You need page_messaging_subscriptions permission to be able to do it.

message:  "https://graph.facebook.com/v2.6/me/messages?access_token=xxxxxxxxxx のリクエストに失敗しました(エラー: 400)。サーバー応答の一部: 
{"error":
{"message": "(#10) This message is sent outside of allowed window. You need page_messaging_subscriptions permission to be able to do it. Learn more about the new policy here: https://developers.facebook.com/docs/messenger-platform/policy-overview",
"type": "OAuthException",
"code": 10,
"error_subcode": 2018065,
...
"

This message is sent outside of allowed window. (このメッセージは許可されたウィンドウ以外から送信されています)You need page_messaging_subscriptions permission to be able to do it. (そのためにはpage_messaging_subscriptions permissionが必要です)

24時間メッセージの時間枠外にテキストメッセージを送信しようとすると出る。
プラットフォームポリシーの概要 - Messengerプラットフォーム

(#230) Requires pages_messaging permission to manage the object

アプリで申請している権限が足りない。
アプリマネージャーの設定で必要な権限を付与すればOK。
基本的に新規アプリ・ページでの動作確認中にしか発生しない。

(#1200) Temporary send message failure. Please try again later.

message:  "https://graph.facebook.com/v2.6/me/messages?access_token=xxxxxxxxxx のリクエストに失敗しました(エラー: 400)。サーバー応答の一部: 
{"error":
{"message":"(#1200) Temporary send message failure. Please try again later.",
"type":"OAuthException",
"code":1200,
"error_subcode":2018024,"
...

メッセージ送信に失敗。
Facebookサーバー側の問題で稀に発生?

Temporary send message failure. (一時的なメッセージ送信エラー)Please try again later. (後ほどもう一度お試しください)

Messenger Platform is experiencing failures - 開発者向けFacebook

(#100) Title is required for this quick reply content type

message:  "(#100) Title is required for this quick reply content type
"code":100,
"error_subcode":2018098

Quick Repliesのオブジェクト生成時に必要なパラメータが不足してる時とかに出る。
基本的に開発環境での動作確認中にしか発生しない。

(#100) Invalid web URL provided

message: "https://graph.facebook.com/v2.6/me/messages?access_token=xxxxxxxxxx のリクエストに失敗しました(エラー: 400)。サーバー応答の一部: 
{"error":
{"message":"(#100) Invalid web URL provided",
"type":"OAuthException",
"code":100,
"error_subcode":2018030,
...

広告のカスタムテンプレートで無効なURL(httpsではなくhttpのIPアドレス指定?)を設定した際に発生。

An unknown error occurred

message: "https://graph.facebook.com/v2.6/me/messages?access_token=xxxxxxxxxx のリクエストに失敗しました(エラー: 500)。サーバー応答の一部: 
{"error":
{"code":1,
"message":"An unknown error occurred",
"error_subcode":99}} 

直訳すると「不明なエラーが発生しました」

…じゃあ何もわからんわ/(^o^)\

An unexpected error has occurred. Please retry your request later.

message: "https://graph.facebook.com/v2.6/me/messages?access_token=xxxxxxxxxx のリクエストに失敗しました(エラー: 500)。サーバー応答の一部: 
{"error":
{"message":"An unexpected error has occurred. Please retry your request later.",
"type":"OAuthException",
"is_transient":true,
"code":2,
...

おそらくFacebookサーバー側のエラー。
何らかの理由で送信処理がコケたのでリトライ処理が必要。

Error validating access token: The session has been invalidated because the user changed their password or Facebook has changed the session for security reasons.

アクセストークンが無効になっている。
トークンの再発行&差し替え等が必要。

トークンの有効期限や付与されている権限を確認するには「アクセストークンデバッガー」を使うと楽。
https://qiita.com/unsoluble_sugar/items/8c2a4003878098959724

アクセストークンが無効になるケース

  • アクセストークンの有効期限切れ
  • ユーザーがアプリ認証後にアカウントのパスワード変更をする
  • ユーザーがアプリ認証を解除する
  • ユーザーがFacebookからログアウトする

※ここで言う「ユーザー」は、アクセストークンを発行したユーザーのこと

いずれもHTTP 400エラーを返す。
ユーザーがアプリ認証を解除した場合は再認証させる必要あり。
How-To: Handle expired access tokens - 開発者向けFacebook

不具合報告ページも活用しよう

原因不明のエラー系は、すでに不具合報告ページに挙がっている場合もある。
プラットフォームの不具合報告 - 開発者向けFacebook

自力で調べても分からず解決が急務な時は、こちらから不具合報告をしてみると良いかと。

7
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
2