3

试图弄清楚如何在 Hangouts Chat 中将 webhook 消息发布到聊天室中的现有线程。

当我发布到 webhook URL 时,我得到以下响应:

{
    "name": "spaces/123123123123/messages/128391203812903809128",
    "sender": {
        "name": "users/u4i3u4oi32u5oi23u4o23",
        "displayName": "Mecha",
        "avatarUrl": "",
        "email": "",
        "type": "BOT"
    },
    "text": "",
    "cards": [
        {
            "header": {
                "title": "Some Title",
                "subtitle": "Some Subtitle",
                "imageStyle": "IMAGE",
                "imageUrl": "Some Image URL",
                "imageAltText": ""
            },
            "sections": [],
            "cardActions": [],
            "name": ""
        }
    ],
    "previewText": "",
    "annotations": [],
    "thread": {
        "name": "spaces/123123123123/messages/128391203812903809128"
    },
    "space": {
        "name": "spaces/123123123123",
        "type": "ROOM",
        "displayName": "Chat Room"
    },
    "fallbackText": "",
    "argumentText": "",
    "createTime": "2019-01-25T21:13:03.278543Z"
}

有没有办法在 JSON 响应中使用返回的“线程”来发布到聊天室中的同一线程?

4

1 回答 1

8

我想到了。您可以在返回的 JSON 中获取线程值。

在这种情况下,它是:

"thread": {
        "name": "spaces/123123123123/messages/128391203812903809128"
    },

并将其添加到 JSON 中,然后发送下一个请求:

{ 
  "cards": [
    {
        "header": {
            "title": "Some Title",
            "subtitle": "Some Subtitle",
            "imageStyle": "IMAGE",
            "imageUrl": "Some Image URL",
            "imageAltText": ""
        },
        "sections": [],
        "cardActions": [],
        "name": ""
    }
 ],
  "thread": {
        "name": "spaces/123123123123/messages/128391203812903809128"
    }
}
于 2019-01-30T00:48:11.747 回答