Dialogflow CX Flows
Manage flows and pages in Google Dialogflow CX via REST API for organizing conversation paths.
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 Flows
CODEBLOCK3
Create Flow
CODEBLOCK4
List Pages
CODEBLOCK5
Create Page
CODEBLOCK6
Key Resources
| Resource | Description |
|---|
| Flows | Conversation paths within an agent |
| Pages |
States within a flow |
|
Transition Routes | Routing logic between pages |
|
Versions | Immutable snapshots of flows |
Quick Reference
For detailed API reference:
Scripts
- -
scripts/flows.py — CLI wrapper for flows and pages operations
Usage
CODEBLOCK7
Tips
- - Every agent has a default "Default Start Flow"
- Pages represent conversation states
- Use transition routes to move between pages based on intents or conditions
- Train flows after making changes to update NLU
Dialogflow CX 流程
通过 REST API 管理 Google Dialogflow CX 中的流程和页面,用于组织对话路径。
前提条件
- - 已启用 Dialogflow CX API 的 Google Cloud 项目
- 具有 Dialogflow API 访问权限的服务账号或 OAuth 凭据
- 已认证的 gcloud CLI 或持有者令牌
身份验证
选项 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/${AGENTID}/flows \
-H Authorization: Bearer ${TOKEN}
创建流程
bash
curl -X POST \
https://dialogflow.googleapis.com/v3beta1/projects/${PROJECT
ID}/locations/${LOCATION}/agents/${AGENTID}/flows \
-H Authorization: Bearer ${TOKEN} \
-H Content-Type: application/json \
-d {
displayName: 预订流程,
description: 处理航班预订对话
}
列出页面
bash
curl -X GET \
https://dialogflow.googleapis.com/v3beta1/projects/${PROJECT
ID}/locations/${LOCATION}/agents/${AGENTID}/flows/${FLOW_ID}/pages \
-H Authorization: Bearer ${TOKEN}
创建页面
bash
curl -X POST \
https://dialogflow.googleapis.com/v3beta1/projects/${PROJECT
ID}/locations/${LOCATION}/agents/${AGENTID}/flows/${FLOW_ID}/pages \
-H Authorization: Bearer ${TOKEN} \
-H Content-Type: application/json \
-d {
displayName: 收集目的地,
entryFulfillment: {
messages: [
{
text: {
text: [您想飞往哪里?]
}
}
]
}
}
关键资源
流程中的状态 |
|
转换路由 | 页面之间的路由逻辑 |
|
版本 | 流程的不可变快照 |
快速参考
有关详细的 API 参考:
脚本
- - scripts/flows.py — 流程和页面操作的 CLI 封装
使用方法
bash
python scripts/flows.py list-flows --agent AGENT_NAME
python scripts/flows.py list-pages --flow FLOW_NAME
python scripts/flows.py get-flow --flow FLOW_NAME
python scripts/flows.py get-page --page PAGE_NAME
提示
- - 每个代理都有一个默认的“默认起始流程”
- 页面代表对话状态
- 使用转换路由根据意图或条件在页面之间移动
- 更改后训练流程以更新 NLU