Logs incoming SMS numbers and messages into a Google Sheets spreadsheet.
To use this function, you will need a Google Sheets spreadsheet you want to log messages into, and a Google Cloud service account and associated authentication key. See the Google documentation on creating a service account and generating an authentication key for details. Ensure that your authentication key is in JSON format, and that it is saved to a file named auth.private.json
under the assets
directory for this function.
This project requires some environment variables to be set. To keep your tokens and secrets secure, make sure to not commit the .env
file in git. When setting up the project with twilio serverless:init ...
the Twilio CLI will create a .gitignore
file that excludes .env
from the version history.
In your .env
file, set the following values:
Variable | Description | Required |
---|---|---|
GOOGLE_CREDENTIALS | The path to your Google service account authentication JSON file | Yes |
DOCUMENT_ID | The document ID for your Google Sheets spreadsheet | Yes |
SHEET_NAME | The spreadsheet name to log to within your Google Sheets document | Yes |
- Install the Twilio CLI
- Install the serverless toolkit
twilio plugins:install @twilio-labs/plugin-serverless
- Initiate a new project
twilio serverless:init example --template=google-sheets && cd example
- Start the server with the Twilio CLI:
twilio serverless:start
- Open the web page at https://localhost:3000/index.html and follow the instructions to test your application.
ℹ️ Check the developer console and terminal for any errors, make sure you've set your environment variables.
Deploy your functions and assets with either of the following commands. Note: you must run these commands from inside your project folder. More details in the docs.
With the Twilio CLI:
twilio serverless:deploy