部分產品和功能正在重新命名中。我們也正在將生成式應對手冊和流程功能遷移至單一整合式控制台。請參閱
詳細說明。
  
        
 
     
  
  
  
    
  
  
  
    
  
  
    
      使用 API 管理意圖
  
      
    
  
  
  
  
  
    
  
  
    
    
    
    
一般來說,您會使用控制台建立及刪除意圖。
不過,在某些進階情境下,使用 API 可能會比較容易。
建立意圖
下列範例說明如何呼叫 Intent 型別的 Create 方法。
  
  
  
  
  
    
  
  
  REST
  
  
  
  
  
  
  
    
    
  
  
  
    
  
  使用任何要求資料之前,請先替換以下項目:
  - PROJECT_ID:您的 Google Cloud 專案 ID
- REGION_ID:您的區域 ID
  
- AGENT_ID:您的虛擬服務專員 ID
  HTTP 方法和網址:
  POST https://REGION_ID-dialogflow.googleapis.com/v3/projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID/intents
JSON 要求主體:
  
{
  "displayName": "My intent display name"
}
如要傳送要求,請展開以下其中一個選項:
  curl (Linux、macOS 或 Cloud Shell)
  
  
    
      
    
  
  
    
      將要求主體儲存在名為 request.json 的檔案中,然後執行下列指令:
    
  
  
  
    
  
  
  
  
  
  
  
    
  
  
  
  
  
    
  
  
  
    
  
  
  
  
  curl -X POST \
     -H "Authorization: Bearer $(gcloud auth print-access-token)" \
     -H "x-goog-user-project: PROJECT_ID" \
     -H "Content-Type: application/json; charset=utf-8" \
     -d @request.json \
     "https://REGION_ID-dialogflow.googleapis.com/v3/projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID/intents"
  PowerShell (Windows)
  
  
    
      
    
  
  
    
      將要求主體儲存在名為 request.json 的檔案中,然後執行下列指令:
    
  
  
  
    
  
  
  
  
  
    
    
  
  
  
  
  
  
  
    
    
  
  
  
  
  
  
    
  
  
  
    
  
  
  
    
  
  
  
  
    
  
  $cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred"; "x-goog-user-project" = "PROJECT_ID" }
Invoke-WebRequest `
    -Method POST `
    -Headers $headers `
    -ContentType: "application/json; charset=utf-8" `
    -InFile request.json `
    -Uri "https://REGION_ID-dialogflow.googleapis.com/v3/projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID/intents" | Select-Object -Expand Content
    您應該會收到如下的 JSON 回應:
    
  
{
  "name": "projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID/intents/INTENT_ID",
  "displayName": "My intent display name",
  "priority": 500000
}
  
  
  
  
  
  
  
  
  
  
  
 
更新意圖
欄位遮罩指南說明如何更新意圖的個別欄位。
刪除意圖
下列範例說明如何呼叫 Intent 型別的 Delete 方法。
  
  
  
  
  
    
  
  
  REST
  
  
  
  
  
  
  
  
  
  
    
  
  使用任何要求資料之前,請先替換以下項目:
  - PROJECT_ID:您的 Google Cloud 專案 ID
- REGION_ID:您的區域 ID
  
- AGENT_ID:您的虛擬服務專員 ID
- INTENT_ID:您的意圖 ID,可在建立回應中找到
  HTTP 方法和網址:
  DELETE https://REGION_ID-dialogflow.googleapis.com/v3/projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID/intents/INTENT_ID
如要傳送要求,請展開以下其中一個選項:
  curl (Linux、macOS 或 Cloud Shell)
  
  
    
      
    
  
  
  執行下列指令:
  
  
  
  
    
  
  
  
  
  
  
  
    
  
  
  
  
  
  
  
  
  
  
  curl -X DELETE \
     -H "Authorization: Bearer $(gcloud auth print-access-token)" \
     -H "x-goog-user-project: PROJECT_ID" \
     "https://REGION_ID-dialogflow.googleapis.com/v3/projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID/intents/INTENT_ID"
  PowerShell (Windows)
  
  
    
      
    
  
  
  執行下列指令:
  
  
  
  
    
  
  
  
  
  
    
    
  
  
  
  
  
  
  
    
    
  
  
  
  
  
  
    
  
  
  
  
  
  
  
  
    
  
  $cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred"; "x-goog-user-project" = "PROJECT_ID" }
Invoke-WebRequest `
    -Method DELETE `
    -Headers $headers `
    -Uri "https://REGION_ID-dialogflow.googleapis.com/v3/projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID/intents/INTENT_ID" | Select-Object -Expand Content
    您應該會收到執行成功的狀態碼 (2xx) 和空白回應。
    
  
  
  
  
  
  
  
  
  
  
  
 
  
  
  
    
  
  
 
    
  
  
    
    
      
       
         
  
       
    
    
  
  
  除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
  上次更新時間:2025-10-19 (世界標準時間)。
  
  
    
    
    
      
  
    
  
  
    
      [[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-10-19 (世界標準時間)。"],[],[]]