Dialogflow CX Agents
Manage Google Dialogflow CX agents via REST API.
Prerequisites
- - Google Cloud project with Dialogflow CX API enabled
- Service account or OAuth credentials with Dialogflow API access
- INLINECODE0 CLI authenticated OR bearer token
Authentication
Option 1: gcloud CLI (recommended)
CODEBLOCK0
Option 2: Service Account
CODEBLOCK1
API Base URL
CODEBLOCK2
Regional endpoints available:
- -
https://{region}-dialogflow.googleapis.com (e.g., us-central1, europe-west1)
Common Operations
List Agents
CODEBLOCK3
Create Agent
CODEBLOCK4
Get Agent
CODEBLOCK5
Update Agent
CODEBLOCK6
Delete Agent
CODEBLOCK7
Key Resources
| Resource | Description |
|---|
| Agents | Top-level container for flows, intents, entity types |
Quick Reference
For detailed API reference:
Scripts
- -
scripts/agents.py — CLI wrapper for agent management operations
Usage
CODEBLOCK8
Tips
- - Use
locations/global for multi-region agents - Agent IDs are generated automatically on creation
Dialogflow CX 智能体
通过 REST API 管理 Google Dialogflow CX 智能体。
前提条件
- - 已启用 Dialogflow CX API 的 Google Cloud 项目
- 具有 Dialogflow API 访问权限的服务账号或 OAuth 凭据
- 已认证的 gcloud CLI 或持有 bearer 令牌
身份验证
选项 1:gcloud CLI(推荐)
bash
gcloud auth application-default login
TOKEN=$(gcloud auth print-access-token)
选项 2:服务账号
bash
export GOOGLE
APPLICATIONCREDENTIALS=/path/to/service-account.json
TOKEN=$(gcloud auth application-default print-access-token)
API 基础 URL
https://dialogflow.googleapis.com/v3beta1
可用的区域端点:
- - https://{region}-dialogflow.googleapis.com(例如 us-central1、europe-west1)
常用操作
列出智能体
bash
curl -X GET \
https://dialogflow.googleapis.com/v3beta1/projects/${PROJECT_ID}/locations/${LOCATION}/agents \
-H Authorization: Bearer ${TOKEN}
创建智能体
bash
curl -X POST \
https://dialogflow.googleapis.com/v3beta1/projects/${PROJECT_ID}/locations/${LOCATION}/agents \
-H Authorization: Bearer ${TOKEN} \
-H Content-Type: application/json \
-d {
displayName: 我的智能体,
defaultLanguageCode: en,
timeZone: Asia/Kolkata
}
获取智能体
bash
curl -X GET \
https://dialogflow.googleapis.com/v3beta1/projects/${PROJECT
ID}/locations/${LOCATION}/agents/${AGENTID} \
-H Authorization: Bearer ${TOKEN}
更新智能体
bash
curl -X PATCH \
https://dialogflow.googleapis.com/v3beta1/projects/${PROJECT
ID}/locations/${LOCATION}/agents/${AGENTID} \
-H Authorization: Bearer ${TOKEN} \
-H Content-Type: application/json \
-d {
displayName: 更新后的智能体名称
}
删除智能体
bash
curl -X DELETE \
https://dialogflow.googleapis.com/v3beta1/projects/${PROJECT
ID}/locations/${LOCATION}/agents/${AGENTID} \
-H Authorization: Bearer ${TOKEN}
关键资源
快速参考
有关详细的 API 参考:
脚本
- - scripts/agents.py — 智能体管理操作的 CLI 封装
使用方法
bash
python scripts/agents.py list --project PROJECT_ID --location LOCATION
python scripts/agents.py create --project PROJECT_ID --location LOCATION --name 我的智能体
python scripts/agents.py get --project PROJECT
ID --location LOCATION --agent AGENTID
python scripts/agents.py update --agent AGENT_NAME --name 新名称
python scripts/agents.py delete --agent AGENT_NAME
提示
- - 对于多区域智能体,请使用 locations/global
- 智能体 ID 在创建时自动生成