This project demonstrates the integration of Twilio and Google Calendar for managing events through WhatsApp messages. Users can interact with their Google Calendar by sending WhatsApp messages to a Twilio phone number.
-
Google Cloud Platform (GCP) Account:
- Create a GCP account: Google Cloud Console.
- Set up a project and note down the Project ID.
-
Deploy Flask App to Google Cloud App Engine:
- Install Google Cloud SDK: Follow the instructions for your OS [Installing Google Cloud SDK](https://cloud.google.com/sdk/docs/install).
- Set Up a Google Cloud Project: Create a new project on the [Google Cloud Console](https://console.cloud.google.com/). Enable billing.
- Enable App Engine API: Enable the App Engine API for your project.
- Configure Google Cloud SDK: Run `gcloud init` and follow the instructions.
- Navigate to Your Flask App Directory: Open a terminal and go to your Flask app directory.
- Create `app.yaml` File: Create a file named `app.yaml` with the provided content in the README.
- Install Gunicorn: Run `pip install gunicorn` to install Gunicorn.
- Deploy to App Engine: Run `gcloud app deploy` to deploy your Flask app.
- Access Your App: After deployment, you will get a public URL for your app.
-
Google Calendar API:
- Enable the Google Calendar API for your project.
- Create credentials (OAuth client ID) for the project. Download the JSON file containing client ID and secret.
-
Google Cloud Storage:
- Set up a Google Cloud Storage bucket to store OAuth tokens.
- Note the bucket name.
-
Service Account:
- Create a service account with the necessary permissions (Google Calendar API, Google Cloud Storage).
- Download the JSON key file for the service account.
-
Twilio Account:
- Create a Twilio account: Twilio Console.
- Acquire a Twilio phone number configured for WhatsApp.
- Clone the repository:
git clone https://github.com/your-username/your-project.git
cd your-project
- Install dependencies:
pip install -r requirements.txt
- Copy the Google Calendar API credentials JSON file and the service account JSON key file to the project directory.
- Run the Flask web application:
There is no need to run the application locally, but you can run it to check if it is working.
python app.py
The application will be accessible at http://localhost:5000
.
- Configure your Twilio WhatsApp phone number:
- Log in to Twilio Console.
- Navigate to your Twilio WhatsApp phone number.
- Set the "Incoming Webhook" to your gcloud uri
https://PROJECT_ID.REGION_ID.r.appspot.com/webhook
.
- Send a WhatsApp message to your Twilio phone number with commands like:
next events
: List upcoming events.add event <event details>
: Add a new event to the calendar.
- Receive WhatsApp responses with relevant information.
- If you encounter issues with Google Cloud Storage permissions, ensure that the service account has the necessary roles (e.g., Storage Object Admin) on the storage bucket.
- Check the Twilio WhatsApp logs for any errors related to webhook requests.
- Quickstart calendar API: Google quickstart.
- Get URL for deployed app: Tutorial.