Giter Site home page Giter Site logo

lilaobot's Introduction

Welcome to lilaobot ๐Ÿ‘‹

Documentation Twitter: lhauspie

lilaobot allows call for offers from various sources (currently OBMS and Little Big Connection are envisionned) to be gathered from sources and to be published into Slack channel

Work in progress ๐Ÿšง

Setup

Deployment

On each commit, Github Action (.github/workflows/main.yml) applies Terraform conf (located at ./terraform), to deploy the GCP Functions (located at ./functions)

Terraform state is saved in a Google Cloud Storage named lilaobot-terraform-state

Requirements

  • a GCS bucket to store Terraform's state
  • a GCP Service Account, with following roles:
    • Cloud Function Developer
    • Service Account User
    • Storage Object Admin
    • Storage Admin
  • Secrets on Github repository:
    • GCP_SA_KEY (service account credentials, a JSON file)
    • GCP_PROJECT (project id)
  • Create an OAuth Client ID Credentials through GCP Console -> APIS & Services -> Credentials
  • Secrets on GCP through GCP Console -> Security -> Secret Manager:
    • oauth2-client-id: Client ID from previously created OAuth Credentials
    • oauth2-client-secret: Client ID from previously created OAuth Credentials
    • slack-bot-token: The token of the Slackbot Application (https://api.slack.com/authentication/basics)

Resources

This project is based on this article from Google, without the image part.

Below, the goal of this actual project: Lilaobot architechure diagram

How to Use

After deployment you can activate the bot through this URLs : https://europe-west1-lilaobot.cloudfunctions.net/oauth2init

BEWARE This will send all your new mails into Zenika Slack channel named project-lilaobot

NOTE This URLs is retrievable in the GCP Console -> Cloud Functions -> Trigger -> HTTP.

Once this url is invoked (and authorization is granted) the function is authorized to read user mails.

How does it works ?

Lilaobot sequence diagram

Two main flows are visible here: initialization and transfer of message

Author

๐Ÿ‘ค Logan Hauspie

๐Ÿค Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page.

Show your support

Give a โญ๏ธ if this project helped you!


This README was generated with โค๏ธ by readme-md-generator

lilaobot's People

Contributors

acevedor avatar enwooz avatar le-bit avatar lhauspie avatar riduidel avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

lilaobot's Issues

oauth module is not tested

Actually oauth module is not tested, it should be, maybe by mocking libraries with example data (retrieve from real world usage).
It will greatly help understanding the code.

Read all emails from last historyId after recieving Pub/Sub message

Pub/Sub Message contains the email address and an historyId. Today we only read the last recieved email. By this way we might miss some email if several emails are recieved ate the almost same time.

It could be nice to read all the recieved email since the last historyId becaus an historyId can represent a batch of emails.

Cleanup branches !

There are at least ten branches which are not currently merged in main.
Can you please remove the branches you have created that contain code merged into main (be it directly or through a cherry-pick or any other cumbersome git-fuckery ?

Branches to analyze are

Can you either deet branch remotely or comment with the PR linked to this branch ?

Error when there is only one message in list

Since #46 implementation, we read a pageToken.
But when here is only one message, pageToken is not sent by GMail API, and as a consequence listMessages fails.

Error is

TypeError: Cannot read property 'pageToken' of undefined at Object.exports.listMessages (/workspace/lib/gmail-api-client.js:67:35) at exports.onNewMessage (/workspace/index.js:119:43) at processTicksAndRejections (internal/process/task_queues.js:95:5)

Retrieve configuration from GCP Secrets

Today the configuration in centralized in files named config.js and config.json.

It could be nice to replace these files by a GCP Secrets to avoid configuration in code base.

Disable gmail watching

Allow users that previously gived the authorization to wtahc his/her email box to disable the watcher.

IaC: get:secrets on Function Service Account

I had to mannualy add permission to access secrets on the default Service Account used to execute the Function :

gcloud secrets add-iam-policy-binding slack-bot-token \
    --role roles/secretmanager.secretAccessor \
    --member serviceAccount:[email protected]

It could be handled by Terraform, or be a requirement.

Cannot read HTML mails

  • Actually if we receive a mail with HTML, process will fail.
  • Slack does not support HTML

Stop using a pure gmail address

In our context, we should use a @zenika.com email address.

I'm currently discussing with internal IT department to have one provisionned

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.