Hangouts Chat: get all messages in a thread

Viewed 1924
1 Answers

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.

Related