将Webhook发布到现有线程

时间:2019-01-25 21:23:10

标签: hangout 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响应中返回的“线程”将其发布到聊天室中的同一线程?

1 个答案:

答案 0 :(得分:0)

我知道了。您可以在返回的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"
    }
}