Posting a Webhook to Existing Thread

人盡茶涼 提交于 2020-04-16 06:13:02

问题


Trying to figure out how to have a post a webhook message in Hangouts Chat to an existing thread in a chat room.

When I post to the webhook URL, I get the following response:

{
    "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"
}

Is there a way to use the returned "thread" in the JSON response to post to the same thread in the chat room?


回答1:


I figured it out. You can take the thread value in returned JSON.

In this case, it was:

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

And add it to the JSON, you send in your next request:

{ 
  "cards": [
    {
        "header": {
            "title": "Some Title",
            "subtitle": "Some Subtitle",
            "imageStyle": "IMAGE",
            "imageUrl": "Some Image URL",
            "imageAltText": ""
        },
        "sections": [],
        "cardActions": [],
        "name": ""
    }
 ],
  "thread": {
        "name": "spaces/123123123123/messages/128391203812903809128"
    }
}


来源:https://stackoverflow.com/questions/54372950/posting-a-webhook-to-existing-thread

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!