Hangouts Chat: get all messages in a thread
Asked Answered
S

1

6

Is there a way to get all messages belonging to a thread?

We know from https://developers.google.com/hangouts/chat/reference/rest/v1/spaces.messages#Message that a Message belongs to a Thread, is there an API to fetch all messages for a given thread?

Sergiosergipe answered 9/6, 2019 at 17:20 Comment(0)
A
3

I believe that is not possible to get all the messages in a thread, by security design. A bot only receives an event when it is directly mentioned in a message and is only granted access to the text of that message.

The event object received by the bot includes a message object with details of the message, including a reference to the thread.

I wrote a simple Apps Script bot whose onMessage function returns the event object as JSON. The message part of the event provides very limited information about the thread:

    "thread": {
        "retentionSettings": {
            "state": "PERMANENT"
        },
        "name": "spaces/sKkv0fAAAAE/threads/F6qY-rYiwr0"
    },

This behaviour is the same for rooms and DMs.

Human users can scan rooms for threads and threads for messages but bots cannot.

Ar answered 19/9, 2019 at 6:10 Comment(3)
I'm most interested not in the use of the Bot per se but to have an API call (or many of them) that can fetch messages in a thread. For example: how does the Chat app or website does it? There must be some way in which you can group all messages of a thread...Sergiosergipe
I would like that too but, as far as I can tell, currently Google only offers automation and an API for bots. Bots can only run as service accounts, with limited privileges.Ar
There is a feature request for this.Admeasurement

© 2022 - 2024 — McMap. All rights reserved.