Quickstart: Setup

This guide provides all required setup steps to start using Dialogflow.

Before you begin

You should do the following before reading this guide:

  1. Read Dialogflow basics.
  2. Read Editions.

About the GCP Console

The Google Cloud Platform (GCP) Console (visit documentation, open console) is a web UI used to provision, configure, manage, and monitor systems that use GCP products. You use the GCP Console to set up and manage Dialogflow resources.

Create a project

To use services provided by GCP, you must create a project. A project organizes all your GCP resources. A project consists of a set of collaborators, enabled APIs (and other resources), monitoring tools, billing information, and authentication and access controls. You can create one project, or you can create multiple projects and use them to organize your GCP resources in a resource hierarchy. For more information on projects, see the Resource Manager documentation.

The Dialogflow Console (visit documentation, open console) can optionally create a basic project for you when you create an agent. If you plan on using your project for more than just basic access to the Dialogflow Standard Edition, or you plan on using the API, you should create a project with the GCP Console as described below.

We recommend that you create separate projects for experiments, testing, and production. Each project can only create one Dialogflow Agent. If you need multiple agents, you will need to create multiple projects. When creating a project, take note of the project ID. You will need this ID to make API calls.

Google Cloud Platform 프로젝트를 선택하거나 만듭니다.

리소스 관리 페이지로 이동

Enable billing

A billing account is used to define who pays for a given set of resources, and it can be linked to one or more projects. Project usage is charged to the linked billing account. In most cases, you configure billing when you create a project. For more information, see the Billing documentation.

Google Cloud Platform 프로젝트에 결제가 사용 설정되어 있는지 확인하세요.

결제 사용 설정 방법 알아보기

Enable the API

You must enable the Dialogflow API for your project. For more information on enabling APIs, see the Service Usage documentation.

Dialogflow V2 API를 사용 설정합니다.

API 사용 설정

Set up authentication

If you plan to use the Dialogflow API, you need to set up authentication. Any client application that uses the API must be authenticated and granted access to the requested resources. This section describes important authentication concepts and provides steps for setting it up. For more information, see the GCP authentication overview.

About service accounts

There are multiple options for authentication, but it is recommended that you use service accounts for authentication and access control. A service account provides credentials for applications, as opposed to end-users. Service accounts are owned by projects, and you can create many service accounts for a project. For more information, see Service accounts.

About roles

When an identity calls an API, GCP requires that the identity has the appropriate permissions. You can grant permissions by granting roles to a service account. For more information, see the Cloud Identity and Access Management documentation.

For the purpose of trying the Dialogflow API, you can use the Project > Owner role in steps below, which grants the service account full access to the project. For more information on roles specific to Dialogflow, see the Dialogflow access control document.

About service account keys

Service accounts are associated with one or more public/private key pairs. When you create a new key pair, you download the private key. Your private key is used to generate credentials when calling the API. You are responsible for security of the private key and other management operations, such as key rotation.

Create a service account and download the private key file

인증 설정:
  1. GCP Console에서 서비스 계정 키 만들기 페이지로 이동합니다.

    서비스 계정 키 만들기 페이지로 이동
  2. 서비스 계정 목록에서 새 서비스 계정을 선택합니다.
  3. 서비스 계정 이름 필드에 이름을 입력합니다.
  4. 역할 목록에서 프로젝트 > 소유자를 선택합니다.

    참고: 역할 필드가 리소스에 액세스할 수 있도록 서비스 계정을 승인합니다. 나중에 GCP Console을 사용하여 이 필드를 보고 변경할 수 있습니다. 프로덕션 애플리케이션을 개발하는 경우 프로젝트 > 소유자보다 세부적인 권한을 지정합니다. 자세한 내용은 서비스 계정에 역할 부여를 참조하세요.
  5. 만들기를 클릭합니다. 키가 포함된 JSON 파일이 컴퓨터에 다운로드됩니다.

Use the service account key file in your environment

환경 변수 GOOGLE_APPLICATION_CREDENTIALS를 설정하여 애플리케이션 코드에 사용자 인증 정보를 제공합니다. [PATH]를 서비스 계정 키가 포함된 JSON 파일의 파일 경로로 바꾸고 [FILE_NAME]을 파일 이름으로 바꿉니다. 이 변수는 현재 셸 세션에만 적용되므로 새 세션을 연 경우 변수를 다시 설정합니다.

Linux 또는 macOS

export GOOGLE_APPLICATION_CREDENTIALS="[PATH]"

예:

export GOOGLE_APPLICATION_CREDENTIALS="/home/user/Downloads/[FILE_NAME].json"

Windows

PowerShell:

$env:GOOGLE_APPLICATION_CREDENTIALS="[PATH]"

예:

$env:GOOGLE_APPLICATION_CREDENTIALS="C:\Users\username\Downloads\[FILE_NAME].json"

명령 프롬프트:

set GOOGLE_APPLICATION_CREDENTIALS=[PATH]

Install and initialize the Cloud SDK

If you plan to use the Dialogflow API, you need to install and initialize the Cloud SDK. Cloud SDK is a set of tools that you can use to manage resources and applications hosted on GCP. This includes the gcloud command line tool. The following link provides instructions:

Cloud SDK 설치 및 초기화.

Test the SDK and authentication

If you have set up authentication in previous steps, you can use the gcloud tool to test your authentication environment. Execute the following command and verify that no error occurs and that credentials are returned:

gcloud auth application-default print-access-token

That command is used by all Dialogflow command line REST samples to authenticate API calls.

Install the Dialogflow client library

You have three options for calling the API:

The client libraries are available for several popular languages, and these are the recommended option. To install a client library:

C#

Install the Google.Cloud.Dialogflow.V2 package from NuGet. Add it to your project in the normal way (for example by right-clicking on the project in Visual Studio and choosing "Manage NuGet Packages..."). Ensure you enable pre-release packages (for example, in the Visual Studio NuGet user interface, check the "Include prerelease" box).

Alternatively, you can use the NuGet command line interface:

nuget install Google.Cloud.Dialogflow.V2 -PreRelease

Go

go get cloud.google.com/go/dialogflow/apiv2

Java

Maven을 사용한다면 pom.xml 파일에 다음을 추가하세요.
<dependency>
  <groupId>com.google.cloud</groupId>
  <artifactId>google-cloud-dialogflow</artifactId>
  <version>0.93.0-alpha</version>
</dependency>
Gradle을 사용한다면 종속 항목에 다음을 추가하세요.
compile 'com.google.cloud:google-cloud-dialogflow:0.93.0-alpha'
SBT를 사용한다면 종속 항목에 다음을 추가하세요.
libraryDependencies += "com.google.cloud" % "google-cloud-dialogflow" % "0.93.0-alpha"

IntelliJ 또는 Eclipse를 사용하는 경우 다음과 같은 IDE 플러그인을 사용하여 클라이언트 라이브러리를 프로젝트에 추가할 수 있습니다.

이 플러그인은 서비스 계정의 키 관리와 같은 추가 기능을 제공합니다. 자세한 내용은 각 플러그인의 문서를 참조하세요.

Node.js

npm install dialogflow

PHP

composer install google/cloud-dialogflow

Python

pip install dialogflow

Ruby

gem install google-cloud-dialogflow

이 페이지가 도움이 되었나요? 평가를 부탁드립니다.

다음에 대한 의견 보내기...

Dialogflow Documentation
도움이 필요하시나요? 지원 페이지를 방문하세요.