3

I am currently working to dynamically create a Google doc that will store some information and then share that link to Google Chats using a Webhook. I have everything all set up and the code runs, the only thing is when I manually copy and paste the link into Google Chats a little preview of the Doc will pop up with an option to open in Google Chats where it will then break into a split screen and let you view and edit the Doc right there in Chats. See my attached image. Picture of what happens when link is manually shared

However, when I have the webhook send this exact same link into Google Chats, everything is the same except for the fact that it does not give you the option to open in Chats. See my attached image. Webhook's shared Doc

So far I have tried changing the sharing permissions, and sending the Doc as both a Doc and a File type. None of these things have worked so far and I haven't been able to find anyone else with a similar problem or any documentation on this little feature. As far as the scope of this project goes I need whoever will be opening this file to be able to stay in Google Chats which is why I am so bent on making this work. Any help or direction is welcomed.

Thank you!

1 Answers1

1

I tested this, and to the best of my ability I believe this may be intended or a side-effect of webhooks being identified differently from humans.

I tried different mimeTypes in the Content-type header of the request, including just text, and Google apps mimeTypes and the webhook response does identify it as an attachment with "source": "DRIVE_FILE", but it still did not work. I was using a file that worked with my regular account and already had the right sharing permissions. Aside from that there isn't much that we can change according to the webhook docs.

I looked deeper into the page source to compare a user message vs a webhook message and found a few differences:

  • There are a few HTML attributes that mark the webhook posts as user/bot/<id>. This along with other similar attributes clearly sets humans apart from bot posts.
  • In one of the parent <div> where the "Open in chat" prompt can be located, there's an attribute called data-show-docs-card-improvements=. For a human post this is set to true, while a bot post has it set to false.
  • In the div class="dYLOVb UCU1Wd" you can find aria-label="Google Docs, Test doc. Open in Chat." on human posts, but bot posts are missing the seemingly crucial Open in Chat label. This label is actually generated dynamically depending on whether or not the page is wide enough to fit the second panel. But again, it only happens on human posts.
  • Next there's the <div class="NulMW">, which contains the actual "Open in Chat" button. This div exists in bot posts, but it's empty. In human posts it contains the button but it's also populated depending on the width of the page as I mentioned in my previous point.

Aside from that there aren't many differences, but it's clear that bot posts are treated differently from user posts. The actual content of the message is the same but these attributes seem to make the difference, and they come from the server, it's not something that we can manipulate with just the webhook message given the limited features we have. My guess is that this could be on purpose or just an oversight.

My suggestion is to post this in Google's issue tracker to see whether they can categorize this as a bug or as a new feature request. If there's some obscure way to do it maybe the Google engineering team there could share it.

Daniel
  • 3,157
  • 2
  • 7
  • 15