Basic: Schedule a GroupMe bot message

:sunrise: 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

:toolbox: What You’ll Need

  • A GroupMe account
  • A GroupMe bot (we’ll create one below)
  • A Google account

:hammer_and_wrench: Step-by-Step Setup

1. Create Your GroupMe Bot

  1. Go to dev.groupme.com/bots
  2. Click “Create Bot”
  3. Fill in:
    • Name: “MorningBot”
    • Group: Select your GroupMe group
    • Callback URL: Leave blank
  4. Submit and copy your Bot ID

2. Create the Script

  1. Go to script.new to open a new Google Apps Script project
  2. 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);
    }
  }
}
  1. Replace 'YOUR_BOT_ID' with your actual GroupMe Bot ID
  2. 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

  1. In Apps Script, click the clock icon :three_o_clock: (Triggers)
  2. Add a new trigger:
    • Function: sendScheduledMessages
    • Event source: Time-driven
    • Type: Every minute (or every 5 minutes)

:white_check_mark: 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
2 Likes