Skip to content

juliar/quotes-agent

Repository files navigation

This is a service to serve quotes and bios of famous women in STEM. It is used as the webhook for a demo conversational agent built with Dialogflow for the "Building a Conversational Agent" workshop at the 2017 Grace Hopper Conference.

The service is written using Flask-RESTful and deployed using App Engine on Google Cloud Platform.

Before running or deploying, install the dependencies using pip:

pip install -t lib -r requirements.txt

To run the service locally, you can run

dev_appserver.py .

Then you can test an example request:

curl -X POST http://localhost:8080/quotesearch -H "Content-Type: application/json" -d '{"queryResult": {"action": "get_quote_event", "parameters": {"author": "Grace Hopper", "topic": "technology"}}}' 

Example response:

{"followupEventInput": {"parameters": {"author": "Grace Hopper", "quote": "The application of systems techniques has been successful in scientific and technical applications . . . It meets difficulty when it is applied in social and political situations largely because people are not 'well-behaved' mathematical functions, but can only be represented by statistical approximations, and all of the extremes can and do occur."}, "name": "respond_with_quote"}}

To deploy, run

gcloud app deploy app.yaml

The service has one endpoint '/quotesearch'. It accepts POST requests with Content-type application/json as sent by Dialogflow. See the full request format here. It handles 4 actions:

Action Body Output
get_quote_event

Get a quote response as a followup event.
{
 …
 "queryResult": {
  "parameters": {
   "author": "Grace Hopper",
   "topic": "computers"
  },
  "action": "get_quote_event"
  …
 }
}

Both parameters are optional.
{
 "followupEventInput": {
  "name": "respond_with_quote",  
  "parameters": {
   "quote": "computers",
   "author": "Grace Hopper"
  }
 }
}

If there is no applicable quote, |name| will be "quote_not_found" instead.
get_quote_response

Get a quote response as response text.
Same as above, except

"action": "get_quote_response"
{
 "fulfillmentText": "Here’s a quote..."
}
get_bio_event

Get an author bio response as a followup event.
{
 …
 "queryResult": {
  "parameters": {
   "author": "Grace Hopper"
  },
  "action": "get_bio_event"
  …
 }
}

The |author| parameter is required.
{
"followupEventInput": {
  "name": "respond_with_bio",  
  "parameters": {
   "bio": "Grace Hopper..."
  }
 }
}

If there is no matching bio, |name| will be "bio_not_found" instead.
get_bio_response

Get an author bio response as response text.
Same as above, except

"action": "get_bio_response"
{
 "fulfillmentText": "Here’s the bio..."
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages