Auto-Send “Good Morning” Messages in GroupMe with Google Apps Script
Want your GroupMe bot to greet your group every morning—without lifting a finger? This tutorial sets up a Google Apps Script that:
- Sends a “Good morning” message via your GroupMe bot
- Creates a Google Sheet to manage schedule, message, and recurrence
- Lets you customize the time, date, and message easily
What You’ll Need
- A GroupMe account
- A GroupMe bot (we’ll create one below)
- A Google account
Step-by-Step Setup
1. Create Your GroupMe Bot
- Go to dev.groupme.com/bots
- Click “Create Bot”
- Fill in:
- Name: “MorningBot”
- Group: Select your GroupMe group
- Callback URL: Leave blank
- Submit and copy your Bot ID
2. Create the Script
- Go to script.new to open a new Google Apps Script project
- Paste the following code:
const BOT_ID = 'YOUR_BOT_ID'; // Replace with your actual GroupMe Bot ID
function setupSheet() {
const sheet = SpreadsheetApp.create('GroupMe Scheduler');
const range = sheet.getActiveSheet().getRange('A1:D1');
range.setValues([['Date', 'Time', 'Message', 'Recur']]);
const sampleRow = sheet.getActiveSheet().getRange('A2:D2');
sampleRow.setValues([[
Utilities.formatDate(new Date(), Session.getScriptTimeZone(), 'yyyy-MM-dd'),
'07:00',
'Good morning!',
'Daily'
]]);
Logger.log('Sheet created: ' + sheet.getUrl());
}
function sendScheduledMessages() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
const now = new Date();
const today = Utilities.formatDate(now, Session.getScriptTimeZone(), 'yyyy-MM-dd');
const currentTime = Utilities.formatDate(now, Session.getScriptTimeZone(), 'HH:mm');
const data = sheet.getDataRange().getValues();
for (let i = 1; i < data.length; i++) {
const [date, time, message, recur] = data[i];
const shouldSend =
(date === today && time === currentTime) ||
(recur === 'Daily' && time === currentTime);
if (shouldSend) {
const payload = {
bot_id: BOT_ID,
text: message,
};
const options = {
method: 'post',
contentType: 'application/json',
payload: JSON.stringify(payload),
};
UrlFetchApp.fetch('https://api.groupme.com/v3/bots/post', options);
}
}
}
- Replace
'YOUR_BOT_ID'with your actual GroupMe Bot ID - Save the project
3. Run the Setup
- In the Apps Script editor, click the dropdown and run
setupSheet - This will create a Google Sheet and log the URL in View > Logs
4. Set the Trigger
- In Apps Script, click the clock icon
(Triggers) - Add a new trigger:
- Function:
sendScheduledMessages - Event source: Time-driven
- Type: Every minute (or every 5 minutes)
- Function:
You’re Done!
Your bot will now send “Good morning!” at the scheduled time. You can update the sheet to:
- Change the message
- Set a specific date
- Use “Daily” in the Recur column for recurring posts