Site

Muhalvin

Automatically Send Google Calendar Reminders to WhatsApp Using Google Apps Script

Have you ever opened your Google Calendar in the morning and realized — “Wait, I have a meeting in 15 minutes?!”. We’ve all been there. Between deadlines, meetings, and personal plans, it’s easy to forget what’s on your schedule.

Now imagine this: every morning, you automatically get a friendly WhatsApp message reminding you about today’s events — straight from your Google Calendar. No extra apps. No servers. Just Google Apps Script and a simple Fonnte API doing all the magic for you.

Whether it’s a daily stand-up, an important client call, or even your friend’s birthday lunch, this little automation keeps you one step ahead — effortlessly.

What You’ll Build

You’re going to create a simple yet powerful script that:

It’s the kind of smart automation that quietly makes your day smoother — every single morning.

Complete Code

💡 Copy all the code below into your Google Apps Script Editor

// CONFIGURATION
const FONNTE_TOKEN = 'YOUR_FONNTE_TOKEN_HERE'; // 🔒 Replace with your Fonnte token
const CALENDAR_ID = 'primary'; // Change if using a different calendar
const PHONE_NUMBERS = ['6281234567890', '6289876543210']; // International format (no leading 0)
const TIMEZONE = 'Asia/Jakarta';
const MESSAGE_TEMPLATE = '📅 *%EVENT%*\n🕒 Time: %TIME%\n\nDon’t forget to attend!';

// MAIN FUNCTION
function sendTodayEventReminders() {
  const timezone = TIMEZONE;
  const today = new Date();

  // Define start and end of the current day
  const startOfDay = new Date(today);
  startOfDay.setHours(0, 0, 0, 0);

  const endOfDay = new Date(today);
  endOfDay.setHours(23, 59, 59, 999);

  // Fetch today’s events from Google Calendar
  const calendar = CalendarApp.getCalendarById(CALENDAR_ID);
  const events = calendar.getEvents(startOfDay, endOfDay);

  if (events.length === 0) {
    Logger.log('📭 No events found for today.');
    return;
  }

  events.forEach(event => {
    const eventName = event.getTitle();
    const eventTime = Utilities.formatDate(
      event.getStartTime(),
      timezone,
      'HH:mm'
    );

    const message = MESSAGE_TEMPLATE
      .replace('%EVENT%', eventName)
      .replace('%TIME%', eventTime);

    PHONE_NUMBERS.forEach(phone => {
      sendFonnteMessage(phone, message);
    });
  });

  Logger.log(`✅ Total events today: ${events.length}`);
}

// SEND MESSAGE VIA FONNTE
function sendFonnteMessage(phone, message) {
  const url = 'https://api.fonnte.com/send';

  const payload = {
    target: phone,
    message: message,
    countryCode: '62', // optional if using international format
  };

  const options = {
    method: 'post',
    contentType: 'application/json',
    payload: JSON.stringify(payload),
    headers: {
      Authorization: FONNTE_TOKEN,
    },
    muteHttpExceptions: true,
  };

  try {
    const response = UrlFetchApp.fetch(url, options);
    const statusCode = response.getResponseCode();
    const resultText = response.getContentText();

    Logger.log('📤 Fonnte response code: ' + statusCode);
    Logger.log('📩 Fonnte response text: ' + resultText);
  } catch (error) {
    Logger.log('❌ Error sending message: ' + error);
  }
}

// TEST FUNCTION
function testSendFonnte() {
  sendFonnteMessage('6281234567890', '🚀 Test message sent successfully via Fonnte and Google Apps Script!');
}

Setup Instructions

Create a New Script Project

  1. Go to https://script.google.com
  2. Click New Project
  3. Paste the entire code above into the editor

Update Configuration

At the top of the code, edit the following:

const FONNTE_TOKEN = 'YOUR_TOKEN_HERE';
const PHONE_NUMBERS = ['628xxxxxxx', '628yyyyyyyy'];
// You can add multiple numbers

Make sure you have an API Token from Fonnte, which you can get from https://fonnte.com.

Grant Permissions

  1. Run the function testSendFonnte()
  2. Click the (Run) button
  3. When prompted, choose Review permissions → select your Google account → click Allow.
  4. If the test message is sent successfully to your WhatsApp, everything is working correctly.

Create an Automatic Trigger

To send messages automatically every day:

  1. Click the Clock icon (Triggers) in the sidebar
  2. Click + Add Trigger
  3. Select function → sendTodayEventReminders
  4. Choose Event source → Time-driven
  5. Pick the execution time → e.g., “Every day at 07:00”
  6. Click Save

View Activity Logs

To check if everything runs properly:

Final Result

Every morning at the time you set:

  1. The script reads all events scheduled for today in your Google Calendar.
  2. It automatically sends a personalized WhatsApp reminder to all phone numbers you listed.

Example message:

📅 Weekly Project Meeting
🕒 Time: 09:00

Don’t forget to attend!