dialogflow-java-client-v2 icon indicating copy to clipboard operation
dialogflow-java-client-v2 copied to clipboard

dialogflow heartbeat/ping using SDK

Open prayagupa opened this issue 6 years ago • 0 comments

Is there a way to check if my app is able to talk to dialogflow agent using java SDK. The purpose is just to verify the credentials are working and connectivity is working when I deploy my application, before actual traffic flows in.

One way I can think of is make a intent-request itself which is not a good solution in my opinion; I wrote something as below (in clojure using java sdk)

(defn heartbeat [{nlu-agent :nlu-agent utterance :utterance creds-file :creds-file}]
  (try
    (send-intent-request
     {:nlu-agent  nlu-agent
      :utterance  utterance
      :creds-file creds-file})
    "success"
    (catch Throwable e
      (.getMessage e))))

And obviously I'm using credentials.json provided my gcloud which looks as below (taken from https://cloud.google.com/video-intelligence/docs/common/auth#authenticating_with_application_default_credentials);

{
  "type": "service_account",
  "project_id": "project-id",
  "private_key_id": "some_number",
  "private_key": "-----BEGIN PRIVATE KEY-----\n....
  =\n-----END PRIVATE KEY-----\n",
  "client_email": "<api-name>[email protected]",
  "client_id": "...",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://accounts.google.com/o/oauth2/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/...<api-name>api%40project-id.iam.gserviceaccount.com"
}

But don't want to send actual intent-requests in PROD every minute just for the sake of heartbeat.

cc @nnegrey

prayagupa avatar Mar 09 '18 07:03 prayagupa