How to save comments from the Comment Thread component in RetoolDB

Looking to capture and store user feedback or team discussions directly within your Retool App? We'll show you how to save those valuable insights into Retool Database! Whether you're tracking progress, gathering feedback, or just keeping a record of your conversations, this step-by-step process will have you set up in no time.

We'll be using additionalScope. If this is a new concept for you, visit that link first. Here is also a TLDR if you just need a refresher:

Let’s make your app even more collaborative in just three simple steps! :sunglasses:

  1. Create a table on Retool Database (i.e. "comments"). Create a column for the body, and in order to reference the user who sent it, create columns for user_id, name, email, or other references we may need. Here is an example:
    Screenshot 2024-09-04 at 4.08.46 PM

  2. At the App level, create a 'Resource query' to write data to our new table:


    Note: the values for name and user_id are passed dynamically based on who is logged in, we send the comment's body using "additionalScope."

  3. Add an event handler to the 'Comment Thread' component for the 'Submit' event, and run a script to trigger the query to POST the comment, passing the Comment Thread's value as the body.

That's it! When a user sends a new message now...
Screenshot 2024-09-04 at 4.15.02 PM

The component will still register the comment as it always did:
Screenshot 2024-09-04 at 4.35.10 PM

But now we'll see the new entry on Retool Database:

Disclosure

This is a workaround for a feature that isn’t currently natively supported in Retool. While you can delete or edit comments at the database level, these changes won’t reflect in the actual Comment Thread component. The reason is that the component currently doesn't support editing comments or triggering events when a comment is deleted. When this is possible, I'll be happy to come back and update this guide. :slightly_smiling_face:

3 Likes