Webhooksを使うと、Metaソーシャルグラフの特定のオブジェクトに加えられた変更のHTTP通知をリアルタイムで受け取ることができます。例えば、カスタマーからお持ちのInstagramプロアカウントにメッセージが送信されたときに通知を受け取ることができます。Webhooksの通知機能により、メッセージの変更をトラッキングできます。また、変更をトラッキングするためにMessengerプラットフォームのエンドポイントをクエリすると発生してしまうレート制限を回避できます。
InstagramメッセージのWebhooks通知を受け取るには、以下の要件を満たす必要があります。
instagram_basic
、instagram_manage_messages
、pages_manage_metadata
のアクセス許可注: 自分のビジネスのすべてのメッセージアプリで、メッセージWebhooksをサブスクリプション登録する必要があります。
詳しくは、アクセスレベル、アプリモード、アプリにおける権限をご覧ください。
Webhookフィールド | 説明 |
---|---|
| カスタマーがメッセージに対してリアクションするかリアクションを取り消すと、通知が送信されます グラフAPI v12.0以降では、 |
| カスタマーからビジネスに次のものが送信されると、通知が送信されます。
ビジネスからカスタマーにメッセージが送信された場合も、通知が送信されます。ビジネスがカスタマーメッセージに対してリアクションするかリアクションを取り消した場合は、通知は送信されません。 このコールバックは、自分のInstagramアカウントによってメッセージが送信されたときに発生します。メッセージがInstagramアカウント自体から送信されたことを示すために、 |
| カスタマーがIcebreakerオプションまたは汎用テンプレートボタンをクリックすると、通知が送信されます v8.0以降が必要です。 |
| メッセージが受信者によって既読になると、通知が送信されます |
| カスタマーが既存スレッドで、リファーラルパラメーターが指定された |
| メッセージフローに複数アプリが含まれる場合、カスタマーがビジネスに対してメッセージを送信しても、その時点でアプリがスレッドをコントロールしていないと、通知が送信されます。 |
受け取る可能性のあるWebhooks通知のタイプの例を以下に示します。
{ "object": "instagram", "entry": [ { "id": "IGID", // ID of your Instagram Professional account "time": 1569262486134, "messaging": [ { "sender": { "id": "IGSID" }, // Instagram-scoped ID for the customer who sent the message "recipient": { "id": "IGID" }, // ID of your Instagram Professional account "timestamp": 1569262485349, "message": { "mid": "MESSAGE-ID", // ID of the message sent to your business "text": "MESSAGE-TEXT" // Included when a customer sends a message containing text "attachments": [ // Included when a customer sends multiple media attachments or a URL for a story mention or share { "type":"image", // Can be audio, file, image (image or sticker), share, story_mention, or video "payload":{ "url":"LINK" } }, { "type":"video", "payload":{ "url":"LINK" } } ] "is_deleted": true // Included when a customer deletes a message "is_echo": true // Included when your business sends a message to the customer "is_unsupported": true, // Included when a customer sends a message with unsupported media "quick_reply": { // Included when a customer clicks a quick reply "payload": "CUSTOMER-RESPONSE-PAYLOAD" // The payload with the option selected by the customer }, "referral": { // Included when a customer clicks an Instagram Shop product "product": { "id": "PRODUCT-ID" } "referral": { // Included when a customer clicks an CTD ad "ref": "REF-DATA-IN-AD-IF-SPECIFIED" "ad_id": AD-ID, "source": "ADS", "type": "OPEN_THREAD", "ads_context_data": { "ad_title": TITLE-FOR-THE-AD, "photo_url": IMAGE-URL-THAT-WAS-CLICKED, "video_url": THUMBNAIL-URL-FOR-THE-AD-VIDEO, } } "reply_to":{ // Included when a customer sends an inline reply "mid":"MESSAGE-ID" } "reply_to": { // Included when a customer replies to a story "story": { "url":"CDN-URL", "id":"STORY-ID" } } } } ] } ] }
{ "object": "instagram", "entry": [ { "id": "IGID", // ID for your Instagram Professional account "time": 1569262486134, "messaging": [ { "sender": { "id": "IGSID" // Instagram-scoped ID for the customer who sent the message }, "recipient": { "id": "IGID" // ID for your Instagram Professional account }, "timestamp": 1569262485349, "reaction" :{ "mid" : "MESSAGE-ID", "action": "react", // or unreact "reaction": "love", // optional, to unreact if there is no reaction field "emoji": "\u{2764}\u{FE0F}" // optional, to unreact if there is no emoji field } } ] } ] }
{ "object": "instagram", "entry": [ { "id": "IGSID", // ID of your Instagram Professional account "time": 1502905976963, "messaging": [ { "sender": { "id": "IGSID" }, // Instagram-scoped ID for the customer who sent the message "recipient": { "id": "IGID" }, // ID of your Instagram Professional account "timestamp": 1502905976377, "postback": { "mid":"MESSAGE-ID", // ID for the message sent to your business "title": "SELECTED-ICEBREAKER-REPLY-OR-CTA-BUTTON", "payload": "CUSTOMER-RESPONSE-PAYLOAD", // The payload with the option selected by the customer } } ] } ] }
{ "object": "instagram", "entry": [ { "id": "IGSID", // ID of your Instagram Professional account "time": 1502905976963, "messaging": [ { "sender": { "id": "IGSID" // Instagram-scoped ID for the customer who sent the message }, "recipient": { "id": "IGID" // ID of your Instagram Professional account }, "timestamp": 1502905976377, "referral": { "ref": "INFORMATION-INCLUDED-IN-REF-PARAMETER-OF-IGME-LINK" "source": "IGME-SOURCE-LINK" "type": "OPEN_THREAD" // Only supported for existing conversations } } ] } ] }
{ "object":"instagram", "entry":[ { "id":"IGID", // ID for your Instagram Professional account "time":1569262486134, "messaging":[ { "sender":{ "id":"IGSID" // Instagram-scoped ID for the customer who sent the message }, "recipient":{ "id":"IGID" // ID for your Instagram Professional account }, "timestamp":1569262485349, "read":{ "mid":"MESSAGE-ID" } } ] } ] }