Skip to content
Getting Started Guide: Coda API
Share
Explore
Guides

Automated reminders

image.png

In this guide, we'll show you how to set up daily email reminders for a Coda table based on data in your table. In this example, you'll be sending reminders when tasks in your table are either overdue or due today. Note, this is an example using the API - you can also use our automations feature to accomplish this same task.

You can use this approach for both formulaic and non-formulaic columns. You can also extend this example to look at column values periodically and take other types of actions like sending slack messages or text messages.

What you'll learn

How to read from a Coda doc and compare against values in Google App Script
How to send an email using Google Apps Script

Instructions

1. Setup

For this example, we'll have a tasks table with a Status column. The idea is to send out an email each morning with overdue tasks and tasks due today.

Here's a button to configure some example due dates:

Configure Due Dates for Demo


Tasks
0
Task
Due Date
Status
1
Build an ML Model
2
Develop Product Specs
3
Build UI
4
Market the feature
5
Collect Feedback
There are no rows in this table
5
Count

2. Create your script


Head over to
(
) and create a new project. Paste in the following code, replacing the doc ID with this doc's ID (hint: you can use the
), and updating the recipients as needed.

CodaAPI.authenticate(
'abcd1234-efgh-5678-ijkl-1234mnop5678'
); // Replace with your token.

// Replace as needed below.
TASKS_DOC_ID =
'UPDATE WITH YOUR DOC ID'
;
TASKS_TABLE_NAME = 'Tasks';
TASKS_TABLE_TASK_COLUMN = 'Task';
TASKS_TABLE_STATUS_COLUMN = 'Status';
EMAIL_SUBJECT = 'Coda ' + TASKS_TABLE_NAME + ' Reminders';
EMAIL_RECIPIENTS = 'leslie@example.com, ron@example.com';

function sendReminders() {
// Fetch overdue items.
var overdueQuery = '"' + TASKS_TABLE_STATUS_COLUMN + '":"Overdue"';
var overdueItems = CodaAPI.listRows(TASKS_DOC_ID, TASKS_TABLE_NAME, {query: overdueQuery, useColumnNames: true}).items;
Logger.log('Fetched %s overdue task(s)', overdueItems.length);

// Fetch items due today.
var dueTodayQuery = '"' + TASKS_TABLE_STATUS_COLUMN + '":"Due today"';
var dueTodayItems = CodaAPI.listRows(TASKS_DOC_ID, TASKS_TABLE_NAME, {query: dueTodayQuery, useColumnNames: true}).items;
Logger.log('Fetched %s task(s) due today', overdueItems.length);
// Exit early if there are no items.
if (!overdueItems.length && !dueTodayItems.length) {
Logger.log('No overdue tasks or tasks due today. Won\'t send an email!');
}

// Construct the email body.
var messageBody = 'Hi!\n\nHere\'s a friendly automated reminder, sent with Google Apps Script using the Coda API.';

if (overdueItems.length) {
messageBody += '\n\nThe following task(s) are overdue. Please complete them or update their due date:\n';
for (var item of overdueItems) {
messageBody += '\n • ' + item.values[TASKS_TABLE_TASK_COLUMN] + ' [' + item.browserLink + ']';
}
}

if (dueTodayItems.length) {
messageBody += '\n\nThe following task(s) are due today. Don\'t forget to finish them:\n';
for (var item of dueTodayItems) {
messageBody += '\n • ' + item.values[TASKS_TABLE_TASK_COLUMN] + ' [' + item.browserLink + ']';
}
}
// Add a signature. :)
var name = CodaAPI.whoami().name.split(" ")[0];
messageBody += '\n\nThanks,\n' + name;

// Send the email.
Logger.log('Sending email(s) to %s', EMAIL_RECIPIENTS);
MailApp.sendEmail(EMAIL_RECIPIENTS, EMAIL_SUBJECT, messageBody);
}

3. Getting it working

With the script set up, run (▶) your
sendReminders()
function. You (and whoever else you have set up in
EMAIL_RECIPIENTS)
should get an email shortly that looks like this:

image.png

You can now set up a trigger (
image.png
) to run
sendReminders()
every morning at the time of your choosing (see
if you need a refresher).

☑️ Mark the "Automated reminders" guide as complete!

No results from filter
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.