Skip to content

miguelp1986/google-sheets-sms-bot

Repository files navigation

Google Sheets SMS Bot

This project allows you to setup an SMS bot to get information from your Google Sheets. It uses Google Authentication, Google Sheets API, and the Twilio Messaging API.

Google API Setup

Authentication

Setup Permissions for Google Sheets

  • In order for your Google Service Account to be able to access your Google Sheets, you will need to explicitly grant it permissions. From your Google Cloud dashboard, get your service account email and share your Google Sheet with that email address.

Google Sheets Configuration

The Google Sheets configuration that is being used here allows for multiple Google Sheets to be accessed, and allows for multiple SMS messages to be customized for each Google Sheet. Below is an example JSON snippet which shows you how to customize your own message request, response, and sheet data. More information on how to use Google Sheet ranges can be found here: https://developers.google.com/sheets/api/guides/concepts#cell

Example:

{
    "spreadsheets": 
    [
        {
            "spreadsheet_id": "spreadsheet ID",
            "spreadsheet_ranges": [
                {
                    "request_message": "request message",
                    "response_message": "response message",
                    "range": "Sheet range value"
                }
            ]
        },
        {
            "spreadsheet_id": "spreadsheet ID",
            "spreadsheet_ranges": [
                {
                    "request_message": "request message",
                    "response_message": "response message",
                    "range": "Sheet range value"
                }
            ]
        }
    ]
}

Twilio Setup

Load Environment Variables`

There are several environment variables that you will need to load. Some are Flask specific, Google specific, and Twilio specific.

Create an .env file at the root directory of this repository. This is where you will place your environment variables. This application will load the environment variables into your environment. Here's an example.

Variable Value
FLASK_APP Flask application name
FLASK_ENV production or development
FLASK_HOST Flask host name you want to use. If using Docker, use 0.0.0.0.
FLASK_PORT Flask port number
NGINX_HOST_PORT Host port you want NGINX to use
NGINX_CONTAINER_PORT Container port you want NGINX to use
SCOPES Google OAuth 2.0 scopes that you need to request to access Google APIs
GOOGLE_APPLICATION_CREDENTIALS Path to JSON file generated by Google when setting up your service account
SHEETS_CONFIG_FILE Path to sheeets config JSON file
TWILIO_ACCOUNT_SID
TWILIO_AUTH_TOKEN
TWILIO_API_KEY
TWILIO_PHONE_NUMBER
PHONE_NUMBERS
TWILIO_SERVICE_SID
TWILIO_CONVERSATION_SID
TWILIO_MESSAGING_SERVICE_SID

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published