Updating List of Entity Entries of DialogFlow Agent via API

坚强是说给别人听的谎言 提交于 2020-02-07 02:52:11

问题


Have been looking for a way to programmatically update our agent's entity entries for a certain entity type through the DialogFlow API. The purpose is to automate the updating of our entity entries on a scheduled basis (as our entries will be changing daily).

Came across this documentation page by Google on batch updating entity entries but have not been able to get anything better than a 404 when testing.

Have tried sending POST's via Postman using the supplied path and inserting my project name in URL but I believe I may be making naive mistakes as I am new to this area (specifically REST-stuff)

Below is an example of the current 404 response & path used.

We are just looking to get past the 404 error, once we have the contact setup, should be able to figure out auth & the rest.

Thanks in advance


回答1:


There are several things you need to take into account.

The URL should look like this: https://dialogflow.googleapis.com/v2/projects/julia-development-2/agent/entityTypes/actual_id/entities:batchUpdate

  • the "parent" you used in the URL is just the name of the path param
  • make sure "julia-development-2" is the id of your GCP project and not just the name (Hint: when you click the drop-down for selecting a certain GCP project in the google cloud console, both the name and the ID of the project will be visibile in the list)
  • replace "actual_id" with the entity type id

Related to auth:

  • you need a bearer token in the Authorization header
  • to get this token you first need to download a JSON key from your projects service account and set the GOOGLE_APPLICATION_CREDENTIALS environment variable to point to your JSON file. More details about setting up the service account and downloading the JSON key, you can find here: https://cloud.google.com/dialogflow/docs/setup
  • to get the token from the command line you can use

    gcloud auth application-default print-access-token



来源:https://stackoverflow.com/questions/56762053/updating-list-of-entity-entries-of-dialogflow-agent-via-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!