GCP 콘솔에 추가된 Dialogflow API 사용
4586 단어 GoogleCloudPlatformdialogflow
GCP 콘솔에 추가된 Dialogflow API 사용
Dialogflow V2 API가 출시되면서 GCP의 API 콘솔에 Dialogflow가 추가되었으므로 시도하고 싶습니다 
Dialogflow V2 API에 대해 자세히 알고 싶은 분은 이 기사를 참조하십시오. Dialogflow V2 API 소개

GCP 콘솔에 추가된 Dialogflow API
Dialogflow API 사용 준비

Cloud Tools 최신화
$ export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account.json
$ gcloud auth activate-service-account --key-file=service-account-key-file

※이미 동일한 GCP 프로젝트에서 Dialogflow 에이전트를 작성한 경우에는 새로 작성할 수 없습니다.
여기까지 할 수 있으면 준비 완료입니다.
명령줄에서 Intent 만들기
지금까지 Dialogflow 콘솔에서 Intent를 만들고 있다고 생각하지만 콘솔에서 API를 두드려 만들어 보겠습니다.
작성 요청
$ curl -X POST -H "Authorization: Bearer "$(gcloud auth print-access-token) -H "Content-Type: application/json; charset=utf-8" --data "{
'displayName': 'Greeting',
'priority': 500000,
'mlEnabled': true,
'webhookState': 'WEBHOOK_STATE_UNSPECIFIED',
'trainingPhrases': [
{
'type': 'EXAMPLE',
'parts': [
{
'text': 'Hello!'
}
]
}
],
'action': 'greeting',
'messages': [
{
'text': {
'text': [
'Hello!'
]
}
}
],
}" "https://dialogflow.googleapis.com/v2beta1/projects/project-name/agent/intents"
URL의 project-name 부분은 GCP 프로젝트의 ID입니다.
응답
{
"name": "",
"displayName": "Greeting",
"priority": 500000,
"mlEnabled": true,
"action": "greeting",
"messages": [
{
"text": {
"text": [
"Hello!"
]
}
}
]
}
Dialogflow 콘솔 확인

제대로 만들어졌습니다!
명령줄에서 Intent 삭제
다음은 Intent를 삭제합시다!
Intent의 ID 메모
삭제할 Intent를 선택하고 ID를 기록해 둡니다. Intent 페이지의 URL의
editIntent/
이후의 부분이 Intent의 ID입니다.삭제 요청
$ curl -X DELETE -H "Authorization: Bearer "$(gcloud auth print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \
"https://dialogflow.googleapis.com/v2beta1/projects/project-name/agent/intents/intent-id"
URL의 project-name 부분은 GCP 프로젝트의 ID입니다.
URL의 intent-id 부분은 메모를 한 ID로 한다
응답
삭제에 성공하면 빈 응답이 반환됩니다.
$ {}
Dialogflow 콘솔에서 삭제 확인

제대로 삭제되었습니다!
Reference
이 문제에 관하여(GCP 콘솔에 추가된 Dialogflow API 사용), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/flatfisher/items/a0e13aba8761ae5b7e6b텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)