一般來說,您會使用控制台建立及刪除代理程式。不過,在某些進階情境下,使用 API 可能會比較容易。
建立虛擬服務專員
下列範例說明如何為 Agent
型別呼叫 Create
方法。
為代理程式參照選取通訊協定和版本:
通訊協定 | V3 | V3beta1 |
---|---|---|
REST | 服務專員資源 | 服務專員資源 |
RPC | 服務專員介面 | 服務專員介面 |
C++ | AgentsClient | 不適用 |
C# | AgentsClient | 不適用 |
Go | AgentsClient | 不適用 |
Java | AgentsClient | AgentsClient |
Node.js | AgentsClient | AgentsClient |
PHP | 不適用 | 不適用 |
Python | AgentsClient | AgentsClient |
Ruby | 不適用 | 不適用 |
REST
使用任何要求資料之前,請先替換以下項目:
- PROJECT_ID:您的 Google Cloud 專案 ID
- REGION_ID:您的區域 ID
HTTP 方法和網址:
POST https://REGION_ID-dialogflow.googleapis.com/v3/projects/PROJECT_ID/locations/REGION_ID/agents
JSON 要求主體:
{ "displayName": "My display name", "defaultLanguageCode": "en", "timeZone": "America/New_York" }
如要傳送要求,請展開以下其中一個選項:
您應該會收到如下的 JSON 回應:
{ "name": "projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID", "displayName": "My display name", "defaultLanguageCode": "en", "timeZone": "America/New_York", "startFlow": "projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID/flows/00000000-0000-0000-0000-000000000000", "advancedSettings": { "loggingSettings": {} } }
Java
如要向 Dialogflow 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。
Node.js
如要向 Dialogflow 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。
Python
如要向 Dialogflow 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。
刪除代理程式
下列範例說明如何為 Agent
型別呼叫 Delete
方法。
為代理程式參照選取通訊協定和版本:
通訊協定 | V3 | V3beta1 |
---|---|---|
REST | 服務專員資源 | 服務專員資源 |
RPC | 服務專員介面 | 服務專員介面 |
C++ | AgentsClient | 不適用 |
C# | AgentsClient | 不適用 |
Go | AgentsClient | 不適用 |
Java | AgentsClient | AgentsClient |
Node.js | AgentsClient | AgentsClient |
PHP | 不適用 | 不適用 |
Python | AgentsClient | AgentsClient |
Ruby | 不適用 | 不適用 |
REST
使用任何要求資料之前,請先替換以下項目:
- PROJECT_ID:您的 Google Cloud 專案 ID
- REGION_ID:您的區域 ID
- AGENT_ID:您的代理程式 ID,可在代理程式建立回應中找到
HTTP 方法和網址:
DELETE https://REGION_ID-dialogflow.googleapis.com/v3/projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID
如要傳送要求,請展開以下其中一個選項:
您應該會收到執行成功的狀態碼 (2xx) 和空白回應。