You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用Dialogflow处理Facebook Messenger中的非文本贴纸消息?

Fixing Facebook Messenger Like Sticker Recognition in Dialogflow

Got it, let's work through this issue where your Dialogflow chatbot can't recognize that popular blue "like" sticker from Facebook Messenger. Here's a step-by-step breakdown to get it sorted:

1. First, Capture the Sticker's Unique ID

Facebook Messenger stickers aren't just regular images—each official sticker has a unique sticker_id that gets sent in the webhook payload when a user sends it. To grab this ID:

  • Head to your Facebook Developer Dashboard, go to your app's Messenger settings, and open the Webhook Test Console.
  • Send the blue like sticker to your test bot through the console (or directly in Messenger if your bot is set up for testing).
  • Look at the raw JSON response from the webhook. You'll see something like this:
    {
      "entry": [
        {
          "messaging": [
            {
              "message": {
                "attachment": {
                  "type": "image",
                  "payload": {
                    "sticker_id": "123456789012345" // This is the ID you need!
                  }
                }
              }
            }
          ]
        }
      ]
    }
    
  • Copy that sticker_id value—you'll need it later.

2. Set Up Dialogflow to Handle Sticker Payloads

Dialogflow doesn't automatically parse sticker IDs out of the box, so you'll need to use a webhook fulfillment to check for the sticker:

  • In your Dialogflow agent, create a new intent (name it something like "RecognizeLikeSticker").
  • Under Fulfillment, toggle on "Enable webhook call for this intent".
  • Skip adding training phrases for this intent—we'll let the webhook handle the detection based on the raw payload.

3. Write the Fulfillment Code

Here's a quick Node.js example for your Dialogflow fulfillment (you can adapt this to other languages too):

// Dialogflow Fulfillment code (Node.js)
const functions = require('firebase-functions');
const { WebhookClient } = require('dialogflow-fulfillment');

exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
  const agent = new WebhookClient({ request, response });

  function handleLikeSticker(agent) {
    // Extract the sticker ID from the original Messenger payload
    const stickerId = agent.originalRequest.payload.data.message.attachment.payload.sticker_id;
    
    // Replace with the ID you captured earlier
    const targetLikeStickerId = "123456789012345";

    if (stickerId === targetLikeStickerId) {
      agent.add("Love that you liked this! 😊");
    } else {
      agent.add("Got your sticker, but it's not the big blue like one!");
    }
  }

  // Map the intent to your handler function
  let intentMap = new Map();
  intentMap.set('RecognizeLikeSticker', handleLikeSticker);
  agent.handleRequest(intentMap);
});

4. Final Checks

  • Make sure your Dialogflow agent's Messenger integration is fully set up, and the webhook URL is correctly linked to your fulfillment (like Firebase Functions or your own server).
  • Verify that your Facebook app's webhook is subscribed to the messages event—this ensures sticker payloads get sent to Dialogflow.

That should do it! Once deployed, your bot will correctly detect that specific blue like sticker and respond accordingly.

内容的提问来源于stack exchange,提问作者zsemlexd

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 18:27:31