Search code examples
google-hangouts

How to @mention a bot using REST APIs?


Using REST APIs, I'm able to @mention a human user in a chat space/room with the service account of a bot.

For example, the following API call posts a message in space(ID: xyx) tagging the user with ID 118194077000688478880.

API: POST https://chat.googleapis.com/v1/{parent=spaces/xyz}/messages
Body: { 'text' : '<users/118194077000688478880> sample message' }

However, I don't know how to tag a bot in a message using the same API

I inspected the browser and got the bot ID. I tried the following combinations and it didn't work. Suppose the bot ID is 1234567890

{ 'text' : '<users/1234567890> sample message' }
{ 'text' : '<bots/1234567890> sample message' }
{ 'text' : '<users/bots/1234567890> sample message' }

Kindly let me know if it's possible. If so, how? Thanks in advance!


Solution

  • It can't be done, by design, so says Google. Pretty frustating if you ask me.

    Status: Won't Fix (Intended Behavior) Currently it is intended for bots only to be mentioned manually by a user. This is done in order to prevent potential abuse, especially in situations where a bot could @mention and send commands to other bots. This behavior is intended, but you may submit a feature request for this change. Be sure to include use cases for this functionality.

    https://issuetracker.google.com/issues/109759261