Challenge 4: Agent Phone Home
Introduction
Now that we can answer questions about Piped Piper’s HR policies, we want to enhance our agent to call external systems to get answers as well.
In this challenge we will be connecting to an external system system that can be queried to get employee PTO days balance information.
Description
A Cloud Run Function with an HTTP REST api has already been deployed for you. You will need the URL of this endpoint. This can be found in the Google Cloud Console.
You will need to create an OpenAPI Tool to make the call to this endpoint.
You will need a YAML scheme for this tool. We have provided the YAML for you below.
Note Make sure you read the comments as there are some substitutions you need to make.
openapi: 3.0.0
info:
title: Vacation Days API
version: 1.0.0
servers:
- url: https://us-central1-agents-ghacks.cloudfunctions.net # Replace with your root Cloud Run root URL
paths:
/vacation-days: # Matches the function name in your URL
get:
summary: Get remaining vacation days
operationId: getVacationDays
responses:
'200':
description: Number of vacation days remaining
content:
application/json:
schema:
type: object
properties:
vacation_days_left:
type: integer
description: The number of vacation days left.
example: 15 # An example value (this is never actually returned)
For authentication to this endpoint, you need to configure a Service Agent Token and use ID Token. You then need to find the Dialog Flow Service Agent and give it IAM permissions to “invoke” both Cloud Run and Cloud Run Functions.
Once this tool is finished, incorporate it into your Playbook so that questions about number of vacation days are answered with a number.
Note The number of vacation days is generated randomly, so it should always be changing.
Success Criteria
- There is a new tool for calling an HTTP REST endpoint
- The agent uses this new endpoint to answer questions about vacation days such as:
- How many vacation days do I have left?
- How much PTO do I have?
- How much vacation can I take?
- Questions about vacation days always return a different number.