How can I use Dialogflow with Compute Engine API?

8/16/2018

I am trying to build a simple Dialogflow agent and use Fulfillment to call Google Actions which at the end would work with Google Compute Engine API, like for example request would be something like this

POST https://container.googleapis.com/v1/projects/myproject/locations/us-central1-a/clusters?fields=detail%2Clocation%2Cname&key={YOUR_API_KEY}

{
 "cluster": {
  "name": "testapi",
  "initialNodeCount": 2
 }
}
-- JJWatt
dialogflow
google-cloud-platform
google-compute-engine
google-kubernetes-engine

1 Answer

8/16/2018

Every Google Service (API) is available as an SDK in your language of choice. DialogFlow is one of these services, Kubernetes Engine is another.

But every services is available through an SDK and you should use the SDK rather than make REST calls directly.

A strength of Google's model is that the SDKs provide one-stop authentication, logging support and, to a large degree, the SDKs are very consistent; once you know how to use one, you can easily use any. It's Google's job to ensure the challenging tasks of authentication are performed correctly and securely, for example. The developer can focus on writing code to solve their problem.

For these reasons, you should approach this as a problem of writing a solution that combines multiple Google services: DialogFlow and Kubernetes Engine(container.googleapis.com). Find the SDKs for both for your preferred language and then write the code that glues them together:

E.g. Python pseudo-code:

import dialogflow_v2 as dialogflow
from google.cloud import container_v1

client = container_v1.ClusterManagerClient()
...
response = client.create_cluster(project_id, zone, cluster)

Be aware though that there is a Google Cloud API for creating, deleting Kubernetes clusters (the one referenced here) and a distinct Kubernetes API for Python that you may use to create Kubernetes Deployments. Kubernetes is different than other services in this regard.

-- DazWilkin
Source: StackOverflow