Logo
Home
Resources

Product

Custom Workflow

Resources

Blog
Youtube
Template

[GAS Library] Gmail to Slack Forwarder Library

A Google Apps Script library that automatically forwards Gmail messages to Slack channels based on specified labels and conditions.

‍

Demo Video

Over view
Code

Detail

📋 Description

This library provides a simple and powerful way to monitor specific Gmail labels and automatically forward new emails to Slack channels. Perfect for teams that need instant notifications for customer inquiries, sales leads, or other important emails.

Key Features

  • ✅ Multi-language support (English/Japanese)
  • ✅ Customizable message formatting
  • ✅ Timezone support
  • ✅ Duplicate prevention
  • ✅ Error handling and logging
  • ✅ Easy configuration management

🚀 Quick Setup

Step 1: Get Slack Webhook URL

Create a Slack webhook URL by following this guide: How to Get Slack Webhook URL

Step 2: Add Library to Your Project

  1. Create a new Google Apps Script project
  2. Go to "Libraries" → "Add a library"
  3. Enter Library ID: [ 1kldK2eftHl5t8xngwYApWNWkX079ZlwFiMO0zJBhU47dCrj3YlVfXFOf ]
  1. Set identifier: GmailSlackLib
  2. Save

Step 3: Create Your Script

function advancedEmailForwarder() {
  const config = {
    slack: {
      webhookUrl: "https://hooks.slack.com/services/YOUR/WEBHOOK/URL",
      channelId: "#alerts",
      botName: "Company Bot",
      botIcon: ":envelope:",
    },
    gmail: {
      targetLabels: ["Customer-Inquiry", "Sales-Lead"],
      processedLabelName: "Slack-Sent",
      timeWindowMinutes: 10,
      searchLimit: 100,
    },
    language: "ja", // 日本語
    timezone: "Asia/Tokyo"
  };
  
  const forwarder = GmailSlackLib.createForwarder(config);
  const result = forwarder.forwardEmails();
  console.log(result);
}

‍

⚙️ Configuration Options

Slack Configuration

  • webhookUrl: Your Slack webhook URL (required)
  • channelId: Target Slack channel (e.g., "#alerts", "#general")
  • botName: Display name for the bot in Slack
  • botIcon: Emoji icon for the bot (see options below)

Gmail Configuration

  • targetLabels: Array of Gmail labels to monitor
  • processedLabelName: Label added to processed emails
  • timeWindowMinutes: Time window to check for new emails (in minutes)
  • searchLimit: Maximum number of threads to process per run

General Configuration

  • language: Interface language ("en" or "ja")
  • timezone: Timezone for date formatting (see country codes below)

🎨 Bot Icon Options

Choose from these emoji options for your Slack bot:

botIcon: ":envelope:",        // 📧 
botIcon: ":email:",          // 📧 
botIcon: ":incoming_envelope:", // 📨 
botIcon: ":postbox:",        // 📮 
botIcon: ":mailbox:",        // 📫 
botIcon: ":robot_face:",     // 🤖 
botIcon: ":computer:",       // 💻 
botIcon: ":bell:",           // 🔔 
botIcon: ":loudspeaker:",    // 📢
botIcon: ":mega:",           // 📣 
botIcon: ":warning:",        // ⚠️ 
botIcon: ":information_source:", // ℹ️
botIcon: ":white_check_mark:", // ✅ 
botIcon: ":smiley:",         // 😄 
botIcon: ":smile:",          // 😄 
botIcon: ":sunglasses:",     // 😎 
botIcon: ":nerd_face:",      // 🤓 
botIcon: ":ghost:",          // 👻 
botIcon: ":alien:",          // 👽 

‍

🌍 Timezone Examples

Set timezone using standard timezone identifiers. For country-specific codes, refer to: ISO 3166-1 Country Codes

Common timezone examples:

  • "Asia/Tokyo" - Japan
  • "America/New_York" - Eastern US
  • "America/Los_Angeles" - Pacific US
  • "Europe/London" - UK
  • "Europe/Berlin" - Germany
  • "Asia/Shanghai" - China
  • "Asia/Seoul" - South Korea
  • "Australia/Sydney" - Australia

‍

‍

Source Code

HTML
CSS
Javascript

Related Template

Need Customization?

We can customize this sample to match your specific business requirements.

Book Free Consultation

[Hubspot modules] HubSpot Case Study & Customer Interview Module Requirements

[GAS Library] Gmail to Slack Forwarder Library

[Hubspot modules] Achievement & Feature Highlight Module

[GAS Library] Department Classification Library

[Hubspot modules] Feature Section Module

Company Info
Name : SweetsVillage .Inc
CEO :
‍
Tomoo Motoyama

HomeTemplateCustomWorkflow
Terms & ConditionsPrivacy PolicyContact us

Copyright ©SweetsVillage .Inc

Back To Top Image