简体   繁体   English

cloud whatsapp api 区分不同的列表消息

[英]cloud whatsapp api distinguishbetween different list messages

I'm using cloud whatsapp api to build a bot.我正在使用云 whatsapp api来构建机器人。 I have some list messages and I'm trying to distinguish bewteen each one.. for example I'm sending a message list to select employee我有一些列表消息,我试图区分每一个.. 例如,我正在向 select 员工发送消息列表在此处输入图像描述

then I send a message list to select a time然后我一次向 select 发送一个消息列表在此处输入图像描述

if the user select each time, select employee and not select date, I don't have a way to know what the list he selected.如果用户 select 每次都是 select 员工而不是 select 日期,我无法知道他选择的列表是什么。 this is the payload of the time selected这是所选时间的有效载荷

 {
  msg: '{"from":"XXXX","id":"XXXXXX","timestamp":"1660854604","type":"list_reply","data":{"id":"12:00","title":"12:00","context":{"from":"XXXXX","id":XXXXXXX"}}}'

payload of select employee select 员工的有效载荷

{
  msg: '{"from":"xxxxx","id":"xxxxx","timestamp":"1660854672","type":"list_reply","data":{"id":"xxxxx","title":"Yativ","context":{"from":"972524741182","id":"xxxxx"}}}'
}

it looks like the same payload, just the data is different.它看起来像相同的有效载荷,只是数据不同。 I'm looking for any id of list to know this response is from the list of select employee or select time..我正在寻找列表的任何 ID,以了解此响应来自 select 员工或 select 时间列表。

Payload for a message has message object and it has message-id ( id ), that is inside entry[0].changes[0].value.messages[0].id消息的有效负载有消息 object并且它有消息 id ( id ),即在entry[0].changes[0].value.messages[0].id

{
  "object": "whatsapp_business_account",
  "entry": [
    {
      "id": "WHATSAPP_BUSINESS_ACCOUNT_ID",
      "changes": [
        {
          "value": {
              "messaging_product": "whatsapp",
              ...
              "messages": [
                {
                  "id": "wamid.ID", // <===== message id
                  ...
                }
              ]
          },
          "field": "messages"
        }
      ]
    }
  ]
}

See the Example Payload请参阅示例有效负载

You have to store (in the database) the message-id ( id ) from the message send API/endpoint, whenever you send a message to the user,每当您向用户发送消息时,您必须存储(在数据库中)来自消息发送 API/端点的消息 ID( id ),

(this is a response from send message API/endpoint) (这是来自发送消息 API/端点的响应)

{
  "messaging_product": "whatsapp",
  "contacts": [{
      "input": "PHONE_NUMBER",
      "wa_id": "WHATSAPP_ID",
    }]
  "messages": [{
      "id": "wamid.ID" // <==== store this in your database 
    }]
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM