Giter Site home page Giter Site logo

gmail-slack's Introduction

Phone Parsing

Purpose

๐Ÿ“ฌ Not everyone has eyes on a mailbox all the time. A company might send a lot of email campaigns and miss some replies to those campaigns. This Google Apps Script app aims at notifying, directly in Slack, the company when they got an answer to an email campaign.

They hard-code (we'll see that below) the list of labels (cf. Gmail naming conventions) they want want to monitor in their mailbox, and whenever a new message lands in those labels, they get a notification in Slack.

Code organization

Classes

There are three classes files: MailService.js, Slack.js and SheetInterface.js.

In each of these files, there is a single function that acts like a class. A few methods are attached to each of the classes. Methods attached to MailService, for instance, only deal with the user's mailbox (Gmail for the time being). This orginization allows for better code segmentation and clarity.

Variables files

There's a single variables files: variables.js which contains global variables required to run the project.

Main file

This file contains a single "encapsulating" function. This is the function to set a trigger for in Google Apps Script. It's the only function the admin should worry about because it encompasses the whole project's logic.

Installation

Pre-Requisites

  1. You have a Slack Workspace and GMail mailbox.
  2. You've created a new app and a new webhook in your Slack workspace.
  3. (Optional) You've installed @google/clasp and know how to use it in your CLI.
  4. You're following this tutorial.

Tutorial

  1. Fork this repo on your github profile and clone it into your machine.

  2. Create a secret.js file and put your credentials in it, like so:

    function secret() {
      const slackHook = "https://hooks.slack.com/services/****"; // The hook of your app
    
      return Object.freeze({
        slackHook,
      });
    }
  3. In variables.js change the spreadsheet id to the id of the spreadsheet you duplicated:

    return Object.freeze({
        ...
        "SPREADSHEET": {
            "spreadsheetId": "๐Ÿ‘‰ Spreadsheet Id Here ๐Ÿ‘ˆ ",
    });
  4. Still in variables.js add the Gmail mailbox labels you want to monitor:

     return Object.freeze({
       "MAILBOX": ["Label 1", "Label 2", ...],
       ...
     });
    };
  5. Clasp push the code from your local repo to the Google Apps Script project attached to the spreadsheet you just duplicated.

Ackowledgements

Coded with grit ๐Ÿ’ช by Bastien Velitchkine.

gmail-slack's People

Contributors

bvelitchkine avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.