Giter VIP home page Giter VIP logo

mealbot's Introduction

Randomly group people together to get a meal together, and send an email to everyone to tell them what their group is!

  1. (Optional) Install miniconda and create a new environment for this project:

    conda create -n mealbot python=3.10
    conda activate mealbot
    
  2. Install Python 3.10.7 or later.

  3. Go through the Google Workspace Python quickstart

    In this guide, you should set up a Google Cloud project, enable the Gmail API, configure the OAuth consent screen, and create credentials for a desktop application. Store the credentials JSON file as client_secret.json in your working directory.

    Also, make sure to enable the Google Forms and Google Sheets APIs in the Google Cloud project. You can do this by going to the APIs & Services tab on the left, clicking on ENABLE APIS AND SERVICES, searching for Google Forms API and Google Sheets API, and enabling them.

    Note: Whichever test user you add when configuring the OAuth consent screen will be the account that sends the emails. If you want to use a different account, then add that account as a test user. When running MealBot.py for the first time, you will be prompted to log in to the account that you added as a test user.

  4. Create a Google Form for signups

    Make sure there is at least questions for First Name, Last Name, Year, College, and Opt in?. The Opt in? question should be a multiple choice question with the options Yes and No.

    The form should be set to collect email addresses. To do this, go to the Settings tab at the top and hit the dropdown next to Responses. Next to Collect email addresses, select either Responder input (manual input) or Verified (forced to log in to Google).

    Also in the Responses dropdown, it is useful to enable Allow response editing and Limit to 1 response. This will allow people to change their response if they change their mind, and will prevent people from submitting multiple responses for the same person.

    (Optional) I also disabled Restrict to users in <my domain> and its trusted organizations to allow people to use their non domain email addresses.

  5. Create a Google Sheet to track previous groupings

    Make sure to label the first row of column A Week and column B Grouping. This will be used to keep track of who has been grouped together in the past, so that the same people don't get grouped together again. MealBot.py will automatically update this sheet after sending out the emails to reflect the new groupings, filling in the columns starting at row 2.

  6. Find IDs for the Google Form and Google Sheet

    To get the ID for the Google Form/Sheet, open up the form/sheet in editing mode and get the string of characters in the URL before /edit (e.g. 1gyiAJszs2akMHrpErmb_ABPzbKIJU5Pd4OUhVXWNj9Z from https://docs.google.com/forms/d/1gyiAJszs2akMHrpErmb_ABPzbKIJU5Pd4OUhVXWNj9Z/edit).

    To get the IDs for the questions in the Google Form, open up the form in preview mode (click the eye icon in the top right) and open the web inspector. In the Elements tab, click on the search icon and search CP1oW. Go to the section of the search results that has the term viewform and click on each search result that should look like this:

    <div jsmodel="CP1oW" data-params="%.@.[2030661291,&quot;First Name&quot;,null,0,[[1994582991,null,true,null,null,null,null,null,null,null,[]]],null,null,null,null,null,null,[null,&quot;First Name&quot;]],&quot;i5&quot;,&quot;i6&quot;,&quot;i7&quot;,false]">

    For the example above, we can see that this is the First Name question. There are two numbers in the data-params attribute: 2030661291 and 1994582991. The first number is the ID for the question, and the second number is the ID for the question's response. The second number is the one we want. Make sure to convert this decimal number to hexadecimal. Repeat this process for each question in the form.

    Put all these IDs in the file ids.json.

  7. Set up other values

    In ids.json, set the APPLICATION_NAME to the name of your project, OPT_IN_YES to the string that corresponds to the Yes option in the Opt in? question, and OPT_IN_NO to the string that corresponds to the No option in the Opt in? question.

  8. Set up message.txt.

    This is the body of the email that will be sent to each person in PersonList.txt. The string {GroupList} must appear exactly once in the file; it will be replaced with the list of people that were randomly grouped together.

  9. Run python MealBot.py.

    There are a number of options (run MealBot.py -h to see them).

mealbot's People

Contributors

joshuachough avatar aschurman 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.