Django Dialogflow is a web client to chat with Dialogflow agent Appointment Scheduler.
The following sections guide you through configuring, running, and deploying the sample.
Clone the Django app
Clone the repository to your local machine:
git clone https://github.com/priyankavergadia/Django-Dialogflow-Appointment-Scheduler.git
cd into the directory that contains the code/. Alternatively, you can download the sample as a zip and extract it.
When deployed, your app uses the Cloud SQL Proxy that is built in to the App Engine environment to communicate with your Cloud SQL instance. However, to test your app locally, you must install and use a local copy of the Cloud SQL Proxy in your development environment.
Learn more about the Cloud SQL Proxy here.
To perform basic admin tasks on your Cloud SQL instance, you can use the MySQL client.
Note: You must authenticate gcloud to use the proxy to connect from your local machine.
Download and install the Cloud SQL Proxy. The Cloud SQL Proxy is used to connect to your Cloud SQL instance when running locally.
Download the proxy:
curl -o cloud_sql_proxy https://dl.google.com/cloudsql/cloud_sql_proxy.darwin.amd64
Make the proxy executable:
chmod +x cloud_sql_proxy
gcloud sql instances describe [YOUR_INSTANCE_NAME]
Start the Cloud SQL Proxy using the connectionName from the previous step.
./cloud_sql_proxy -instances="[YOUR_INSTANCE_CONNECTION_NAME]"=tcp:3306
Replace [YOUR_INSTANCE_CONNECTION_NAME] with the value of connectionName that you recorded in the previous step.
This step establishes a connection from your local computer to your Cloud SQL instance for local testing purposes. Keep the Cloud SQL Proxy running the entire time you test your app locally.
Next you create a new Cloud SQL user and database.
gcloud sql instances describe [YOUR_INSTANCE_NAME]
To run the Django app on your local computer, you'll need to set up a Python development environment, including Python, pip, and virtualenv. For instructions, refer to Setting Up a Python Development Environment for Google Cloud Platform.
Create an isolated Python environment, and install dependencies:
virtualenv env
source env/bin/activate
pip install -r requirements.txt
Run the Django migrations to set up your models:
python3 manage.py makemigrations
python3 manage.py makemigrations polls
python3 manage.py migrate
Start a local web server:
python3 manage.py runserver
In your web browser, enter this address:
http://localhost:8000/ You should see a simple webpage with the text: "Dialogflow" a text box and submit button. The sample app pages are delivered by the Django web server running on your computer. When you're ready to move forward, press Ctrl+C to stop the local web server.
Create a superuser:
python3 manage.py createsuperuser
Start a local web server:
python3 manage.py runserver
Enter this address in your web browser. To log on to the admin site, use the username and password you created when you ran createsuperuser.
Gather all the static content into one folder. This command moves all of the app's static files into the folder specified by STATIC_ROOT in settings.py:
python3 manage.py collectstatic
Upload the app by running the following command from within the directory of the application where the app.yaml file is located:
gcloud app deploy
Wait for the message that notifies you that the update has completed.
In your web browser, enter this address:
https://<your_project_id>.appspot.com
This time, your request is served by a web server running in the App Engine standard environment.
This command deploys the application as described in app.yaml and sets the newly deployed version as the default version, causing it to serve all new traffic.
When you are ready to serve your content in production, make the following configuration change:
In mysite/settings.py, change the DEBUG variable to False.
Navigate to "https://Set an appointment at 4pm tomorrow for drivers license
and respond to the questions your Dialogflow agent asks. After getting the required information, an appointment will be added to the "Appointment Calendar" calendar.
If you are using a different dialogflow agent then try out your own training phrases to test the chat application.
Licensed under Apache2.0
This code is a sample, should not be used for any potential production workloads.
Your use of this sample is subject to, and by using or downloading the sample files you agree to comply with, the Google APIs Terms of Service.