将 Webhook 发布到现有线程

DLe*_*Lee 3 hangout hangouts-chat

试图弄清楚如何在 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"
}
Run Code Online (Sandbox Code Playgroud)

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

DLe*_*Lee 5

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

在这种情况下,它是:

"thread": {
        "name": "spaces/123123123123/messages/128391203812903809128"
    },
Run Code Online (Sandbox Code Playgroud)

并将其添加到 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"
    }
}
Run Code Online (Sandbox Code Playgroud)