일반적으로 콘솔을 사용하여 인텐트를 만들고 삭제합니다. 그러나 일부 고급 시나리오에서는 API를 사용하는 것이 더 쉬울 수 있습니다.
인텐트 만들기
다음 예시에서는 Intent
유형에 대해 Create
메서드를 호출하는 방법을 보여줍니다.
인텐트 참조의 프로토콜 및 버전 선택:
프로토콜 | V3 | V3beta1 |
---|---|---|
REST | 인텐트 리소스 | 인텐트 리소스 |
RPC | 인텐트 인터페이스 | 인텐트 인터페이스 |
C++ | IntentsClient | 해당 사항 없음 |
C# | IntentsClient | 해당 사항 없음 |
Go | IntentsClient | 해당 사항 없음 |
Java | IntentsClient | IntentsClient |
Node.js | IntentsClient | IntentsClient |
PHP | 없음 | 해당 사항 없음 |
Python | IntentsClient | IntentsClient |
Ruby | 없음 | 해당 사항 없음 |
요청 데이터를 사용하기 전에 다음을 바꿉니다.
- PROJECT_ID: Google Cloud 프로젝트 ID
- REGION_ID: 리전 ID
- AGENT_ID: 에이전트 ID
HTTP 메서드 및 URL:
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
메서드를 호출하는 방법을 보여줍니다.
인텐트 참조의 프로토콜 및 버전 선택:
프로토콜 | V3 | V3beta1 |
---|---|---|
REST | 인텐트 리소스 | 인텐트 리소스 |
RPC | 인텐트 인터페이스 | 인텐트 인터페이스 |
C++ | IntentsClient | 해당 사항 없음 |
C# | IntentsClient | 해당 사항 없음 |
Go | IntentsClient | 해당 사항 없음 |
Java | IntentsClient | IntentsClient |
Node.js | IntentsClient | IntentsClient |
PHP | 없음 | 해당 사항 없음 |
Python | IntentsClient | IntentsClient |
Ruby | 없음 | 해당 사항 없음 |
요청 데이터를 사용하기 전에 다음을 바꿉니다.
- PROJECT_ID: Google Cloud 프로젝트 ID
- REGION_ID: 리전 ID
- AGENT_ID: 에이전트 ID
- INTENT_ID: 만들기 응답에서 발견된 인텐트 ID
HTTP 메서드 및 URL:
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)와 빈 응답을 받게 됩니다.