Hey everyone! I’m working on a project where I need to add comments to Google Docs automatically. You know those cool chat-style comments they’ve added recently? I’m wondering if there’s a way to create and control those using some kind of API or script.
My goal is to have a script that can add new comments to specific cells in a document. It would be awesome if the comment could show up as if it’s from the user running the script.
Has anyone figured out how to do this? I’ve been digging around but haven’t found a clear answer yet. Any tips or pointers would be super helpful!
I’m pretty new to Google Docs automation, so feel free to explain things in simple terms. Thanks in advance for any help you can offer!
I’ve actually tackled a similar project recently, and I can share some insights. While Google Docs API does support comment creation, the chat-like comments are a bit trickier to manage programmatically.
For basic comment functionality, you can use the Google Docs API with a service account. You’ll need to enable the API in your Google Cloud Console and set up the necessary credentials.
However, for the chat-style comments, I found that the API support is limited. These are technically called ‘discussion threads’ in the API documentation. You can create them, but controlling the appearance and behavior as if they’re from the user running the script is challenging.
One workaround I discovered is using Google Apps Script instead. It has better integration with user accounts and can more easily mimic user actions. You’d need to create a bound script in your Google Doc and use the DocumentApp class to manipulate comments.
It’s not a perfect solution, but it might get you closer to what you’re aiming for. Hope this helps point you in the right direction!
I’ve been exploring this area recently and found that the Google Docs API doesn’t fully support the new chat-like comments yet. It’s a bit frustrating, to be honest. However, I’ve had some success using Google Apps Script by creating a bound script in your document, using DocumentApp.getActiveDocument() to access the document, finding the appropriate location with methods like findText() or getCursor(), and then adding a comment with addComment(). Although this approach isn’t perfect, it gives more control over the comment appearance by acting as the current user. Keep in mind there are still limitations, so you may need to experiment to best fit your requirements.
hey there! i’ve been messing with this stuff too. have u tried the apps script route? it’s not perfect, but u can get pretty close to what ur looking for. u gotta create a script in ur doc and use DocumentApp to add comments. it’ll look like they’re coming from u. just remember, it’s not exactly like the chat comments, but it’s something!