【问题标题】:Posting a Webhook to Existing Thread将 Webhook 发布到现有线程
【发布时间】:2019-06-19 17:47:33
【问题描述】:

试图弄清楚如何将 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 响应中使用返回的“线程”来发布到聊天室中的同一线程?

【问题讨论】:

    标签: hangout hangouts-chat


    【解决方案1】:

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

    【讨论】:

    • 请将其标记为已回答,以便人们直接跳转到它
    猜你喜欢
    • 2023-01-10
    • 2013-08-31
    • 2020-04-18
    • 1970-01-01
    • 1970-01-01
    • 2016-07-21
    • 1970-01-01
    • 2023-03-22
    • 2023-03-06
    相关资源
    最近更新 更多