通过API更新DialogFlow Agent的实体条目列表 [英] Updating List of Entity Entries of DialogFlow Agent via API
问题描述
一直在寻找一种通过 DialogFlow API 以编程方式为某个entity type
更新代理的entity entries
的方法.目的是按计划自动执行entity entries
的更新(因为我们的entries
每天都会更改).
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).
在此文档页面上浏览由Google 进行批量更新entity entries
,但在测试时无法获得比404
更好的东西.
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.
尝试使用提供的路径通过邮递员发送POST,并在URL中插入我的项目名称,但是我相信我可能是天真的错误,因为我是这个领域的新手(尤其是REST东西)
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)
以下是当前404
响应&的示例.使用的路径.
Below is an example of the current 404
response & path used.
我们只是希望克服404
错误,一旦我们设置了联系人,就应该能够确定auth&其余的.
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.
推荐答案
您需要考虑几件事.
The URL should look like this: https://dialogflow.googleapis.com/v2/projects/julia-development-2/agent/entityTypes/actual_id/entities:batchUpdate
- 您在URL中使用的父级"只是路径参数的名称
- 确保"julia-development-2"是您的GCP项目的ID,而不仅仅是名称 (提示:当您在Google云控制台中单击用于选择某个GCP项目的下拉菜单时,列表中将同时显示该项目的名称和ID)
- 用实体类型id替换"actual_id"
- 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
与授权有关:
- 您需要在Authorization标头中添加一个承载令牌
- 要获取此令牌,您首先需要从您的项目服务帐户下载JSON密钥,并将GOOGLE_APPLICATION_CREDENTIALS环境变量设置为指向您的JSON文件.有关设置服务帐户和下载JSON密钥的更多详细信息,您可以在这里找到: https://cloud.google.com/dialogflow/docs/setup
-
要从命令行获取令牌,可以使用
- 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应用程序-默认打印访问令牌
gcloud auth application-default print-access-token
这篇关于通过API更新DialogFlow Agent的实体条目列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!