This repository has been archived by the owner on Aug 3, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to use Python 3, App Egine Flex and Dialogflow API V2
Change-Id: Ide235fb43c14f66257fa8d6c0b852347a155ef4f
- Loading branch information
Matt Carroll
committed
Apr 16, 2018
1 parent
a67751d
commit 9a79fc7
Showing
8 changed files
with
76 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
*.pyc | ||
.DS_Store | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,38 @@ | ||
# API.AI Webhook Translation Sample for Python (Flask) | ||
======================================================== | ||
# Dialogflow Fulfillment Translation Sample for Python (Flask) | ||
============================================================== | ||
## Setup Instructions | ||
# Pre-requisites | ||
1. API.AI Agent: Create an account on API.AI and import or restore the agent in <code>translation_agent.zip</code> for your agent (or create a new one) | ||
2. Set the fulfillment URL to the URL of the server on which this sample will be hosted and append <code>/webhook</code> | ||
3. Get a Google Translate API key, by following the first 4 steps of the getting started guide [https://cloud.google.com/translate/docs/getting-started](https://cloud.google.com/translate/docs/getting-started) when you get to step 4 (creating credentials) for the credential type choose "API Key" and fill in the API key in <code>API_KEY</code> in <code>app.py</code> | ||
# Steps: | ||
4. Run <code>pip install requirements.txt</code> | ||
5. Run <code>python app.py</code> | ||
6. Test the responses in API.AI | ||
## Documentation | ||
* API.AI Translate Webhook: [https://docs.api.ai/docs/webhook#webhook-example] | ||
## References and How to report bugs | ||
|
||
### Dialogflow Setup | ||
1. Create an account on Dialogflow | ||
1. Create a new Dialogflow agent | ||
1. Restore the `dialogflow-agent.zip` ZIP file in the root of this repo | ||
1. Go to your agent's settings and then the *Export and Import* tab | ||
1. Click the *Restore from ZIP* button | ||
1. Select the `dialogflow-agent.zip` ZIP file in the root of this repo | ||
1. Type *RESTORE* and and click the *Restore* button | ||
|
||
### Fulfillment Setup | ||
1. Click on the Google Cloud project ID in your agent's setting to open the Google Cloud console | ||
1. Enable the [Google Cloud Translation API](http://console.cloud.google.com/apis/library/translate.googleapis.com/) | ||
1. [Create an API key](https://cloud.google.com/docs/authentication/api-keys#creating_an_api_key) and copy the value into the `API_KEY` varible in `main.py` and save the file | ||
1. Run `pip install -r requirements.txt` | ||
1. Deploy fulfillment to App Engine | ||
1. [Download and authenticate the Google Cloud SDK](https://cloud.google.com/sdk/docs/quickstart-macos) | ||
1. Run `gcloud app deploy`, make a note of the service URL, which will be used in the next step | ||
1. Set the fulfillment URL in Dialogflow to your App Engine service URL | ||
1. Go to your [agent's fulfillment page](https://console.dialogflow.com/api-client/#/agent//fulfillment) | ||
1. Click the switch to enable webhook for your agent | ||
1. Enter you App Engine service URL and append `/webhook` (e.g. `https://translate-10929.appspot.com/webhook`) to the URL field | ||
1. Click *Save* at the bottom of the page | ||
|
||
## How to report bugs | ||
* If you find any issues, please open a bug here on GitHub | ||
How to make contributions? | ||
|
||
## How to make contributions? | ||
Please read and follow the steps in the CONTRIBUTING.md | ||
License | ||
|
||
## License | ||
See LICENSE.md | ||
|
||
## Terms | ||
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](https://developers.google.com/terms/) and the [API.AI's Terms of Use and Privacy Policy](https://api.ai/terms/). | ||
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](https://developers.google.com/terms/) and the [Dialogflow's Terms of Use and Privacy Policy](https://dialogflow.com/terms/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
runtime: python | ||
env: flex | ||
entrypoint: gunicorn -b :$PORT main:app | ||
|
||
runtime_config: | ||
python_version: 3 | ||
|
||
# This sample incurs costs to run on the App Engine flexible environment. | ||
# The settings below are to reduce costs during testing and are not appropriate | ||
# for production use. For more information, see: | ||
# https://cloud.google.com/appengine/docs/flexible/python/configuring-your-app-with-app-yaml | ||
manual_scaling: | ||
instances: 1 | ||
resources: | ||
cpu: 1 | ||
memory_gb: 0.5 | ||
disk_size_gb: 10 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
Flask==0.10.1 | ||
google-api-python-client==1.4.2 | ||
Flask==0.12.2 | ||
google-api-python-client==1.6.6 | ||
gunicorn==19.7.1 |
Binary file not shown.