Best way to implement comments AND comment notifications for a client portal?

The comments block that Softr provides does not offer any notification functionality (as far as I can tell). How are those of you who have built client portals with tasks and discussions/comments going about this? Ideally, if a client leaves a comment on a task, my team would know and if we respond to it, the client will be notified.

edit: I just realized I could build this by using a form and connecting the form to a “comments” table in airtable. The comments table data would then populate a list block filtered for the comments on the particular list item’s page. I think automations could then be set up to handle notifications. (hopefully this can help someone else in the future, until the comments block is more robust!)

Hi Carly, and welcome to the Softr community forum!

A while back, I built some simple email notification automations on top of Softr’s comments block.

Here’s a quick runthrough of how they work. I realize it would be better if I could give you access to an Airtable and a Softr project to see this. That would be some additional work but I can do it if this isn’t enough of a tutorial.

First I added a couple of yes/no fields to the Users table to express preferences for instant notifications and daily digests.

These are exposed in the profile block for a user’s profile:
image

Then I created three automations. The first one sends out notifications of new comments. The second sends out a daily digest of new topics and comments. And the third sends out notifications of new topics.



The scripts for the daily digest automation follow.

First script:

// A script to stop the automation running when no records are found.
// This prevents blank emails being sent.
// See: https://share.support.airtable.com/2NuwnyDD?method=GET
let config = input.config();
let numNotifications = config.numNewTopics + config.numNewComments;
if (numNotifications < 1) {
    throw Error("No forum notifications were found. Aborting so no blank emails are sent.")
}
output.set('numNewTopics', config.numNewTopics);
// output.set('newTopicPlural', (config.numNewTopics > 1) ? 's' : '');
output.set('numNewComments', config.numNewComments);
// output.set('newCommentPlural', (config.numNewComments > 1) ? 's' : '');

Second script:

// Generate a random excerpt for the subject line of the daily digest
let config = input.config();
if (config.newTopics.length) {
  let randomTopic = Math.floor(Math.random() * (config.newTopics.length));
  output.set("excerpt", config.newTopics[randomTopic].substring(0, 40));
} else {
  let randomComment = Math.floor(Math.random() * (config.newComments.length));
  output.set("excerpt", config.newComments[randomComment].substring(0, 40) + "...");
}
2 Likes

That is a very cool setup, thanks so much for sharing!