간단한 응답 (Dialogflow)

Dialogflow에서 탐색

계속을 클릭하여 Dialogflow의 응답 샘플을 가져옵니다. 그런 다음 아래 단계에 따라 샘플을 배포하고 테스트합니다.

  1. 에이전트 이름을 입력하고 샘플의 새 Dialogflow 에이전트를 만듭니다.
  2. 에이전트 가져오기가 완료되면 Go to agent(에이전트로 이동)를 클릭합니다.
  3. 기본 탐색 메뉴에서 Fulfillment로 이동합니다.
  4. 인라인 편집기를 사용 설정한 다음 배포를 클릭합니다. 편집기에 샘플 코드가 포함되어 있습니다.
  5. 기본 탐색 메뉴에서 통합으로 이동한 다음 Google 어시스턴트를 클릭합니다.
  6. 표시되는 모달 창에서 Auto-preview changes를 사용 설정하고 Test를 클릭하여 작업 시뮬레이터를 엽니다.
  7. 시뮬레이터에서 Talk to my test app를 입력하여 샘플을 테스트합니다.
계속

간단한 응답은 채팅 풍선의 형태를 취하며 소리에 텍스트 음성 변환(TTS) 또는 음성 합성 마크업 언어 (SSML)를 사용합니다.

TTS 텍스트는 기본적으로 채팅 풍선 콘텐츠로 사용됩니다. 텍스트의 시각적 측면이 필요에 맞는 경우 채팅 풍선의 표시 텍스트를 지정할 필요가 없습니다.

대화 디자인 가이드라인을 검토하여 이러한 시각적 요소를 작업에 통합하는 방법을 알아볼 수도 있습니다.

속성

그림 1. 간단한 응답의 예 (스마트폰)

간단한 응답에는 다음과 같은 요구사항과 사용자가 구성할 수 있는 선택적 속성이 있습니다.

  • actions.capability.AUDIO_OUTPUT 또는 actions.capability.SCREEN_OUTPUT 기능이 있는 노출 영역에서 지원됩니다.
  • 채팅 말풍선당 글자 수가 640자(영문 기준)로 제한됩니다. 제한보다 긴 문자열은 첫 번째 단어 줄바꿈(또는 공백)에서 640자(영문 기준) 앞으로 잘립니다.

  • 채팅 풍선 콘텐츠는 표음식 하위 집합이거나 TTS/SSML 출력의 전체 스크립트여야 합니다. 이를 통해 사용자는 말하는 내용을 이해하고 다양한 상황에서 이해도를 높일 수 있습니다.

  • 한 턴에 최대 2개의 채팅 대화창을 표시할 수 있습니다.

  • Google에 제출하는 채팅 헤드 (로고)는 192x192픽셀이어야 하며 애니메이션을 적용할 수 없습니다.

그림 2. 간단한 응답의 예 (스마트 디스플레이)

샘플 코드

Node.js

app.intent('Simple Response', (conv) => {
  conv.ask(new SimpleResponse({
    speech: `Here's an example of a simple response. ` +
      `Which type of response would you like to see next?`,
    text: `Here's a simple response. ` +
      `Which response would you like to see next?`,
  }));
});

Java

@ForIntent("Simple Response")
public ActionResponse welcome(ActionRequest request) {
  ResponseBuilder responseBuilder = getResponseBuilder(request);
  responseBuilder.add(
      new SimpleResponse()
          .setTextToSpeech(
              "Here's an example of a simple response. "
                  + "Which type of response would you like to see next?")
          .setDisplayText(
              "Here's a simple response. Which response would you like to see next?"));
  return responseBuilder.build();
}

Node.js

conv.ask(new SimpleResponse({
  speech: `Here's an example of a simple response. ` +
    `Which type of response would you like to see next?`,
  text: `Here's a simple response. ` +
    `Which response would you like to see next?`,
}));

Java

ResponseBuilder responseBuilder = getResponseBuilder(request);
responseBuilder.add(
    new SimpleResponse()
        .setTextToSpeech(
            "Here's an example of a simple response. "
                + "Which type of response would you like to see next?")
        .setDisplayText(
            "Here's a simple response. Which response would you like to see next?"));
return responseBuilder.build();

JSON

아래의 JSON은 웹훅 응답을 설명합니다.

{
  "payload": {
    "google": {
      "expectUserResponse": true,
      "richResponse": {
        "items": [
          {
            "simpleResponse": {
              "textToSpeech": "Here's an example of a simple response. Which type of response would you like to see next?",
              "displayText": "Here's a simple response. Which response would you like to see next?"
            }
          }
        ]
      }
    }
  }
}

JSON

아래의 JSON은 웹훅 응답을 설명합니다.

{
  "expectUserResponse": true,
  "expectedInputs": [
    {
      "possibleIntents": [
        {
          "intent": "actions.intent.TEXT"
        }
      ],
      "inputPrompt": {
        "richInitialPrompt": {
          "items": [
            {
              "simpleResponse": {
                "textToSpeech": "Here's an example of a simple response. Which type of response would you like to see next?",
                "displayText": "Here's a simple response. Which response would you like to see next?"
              }
            }
          ]
        }
      }
    }
  ]
}

SSML 및 사운드

응답에 SSML과 사운드를 사용하면 사운드가 더 세련되게 표현되고 사용자 환경이 개선됩니다. 다음 코드 스니펫은 SSML을 사용하는 응답을 만드는 방법을 보여줍니다.

Node.js

app.intent('SSML', (conv) => {
  conv.ask(`<speak>` +
    `Here are <say-as interpet-as="characters">SSML</say-as> examples.` +
    `Here is a buzzing fly ` +
    `<audio src="https://actions.google.com/sounds/v1/animals/buzzing_fly.ogg"></audio>` +
    `and here's a short pause <break time="800ms"/>` +
    `</speak>`);
  conv.ask('Which response would you like to see next?');
});

Java

@ForIntent("SSML")
public ActionResponse ssml(ActionRequest request) {
  ResponseBuilder responseBuilder = getResponseBuilder(request);
  responseBuilder.add(
      "<speak>"
          + "Here are <say-as interpet-as=\"characters\">SSML</say-as> examples."
          + "Here is a buzzing fly "
          + "<audio src=\"https://actions.google.com/sounds/v1/animals/buzzing_fly.ogg\"></audio>"
          + "and here's a short pause <break time=\"800ms\"/>"
          + "</speak>");
  return responseBuilder.build();
}

Node.js

conv.ask(`<speak>` +
  `Here are <say-as interpet-as="characters">SSML</say-as> examples.` +
  `Here is a buzzing fly ` +
  `<audio src="https://actions.google.com/sounds/v1/animals/buzzing_fly.ogg"></audio>` +
  `and here's a short pause <break time="800ms"/>` +
  `</speak>`);
conv.ask('Which response would you like to see next?');

Java

ResponseBuilder responseBuilder = getResponseBuilder(request);
responseBuilder.add(
    "<speak>"
        + "Here are <say-as interpet-as=\"characters\">SSML</say-as> examples."
        + "Here is a buzzing fly "
        + "<audio src=\"https://actions.google.com/sounds/v1/animals/buzzing_fly.ogg\"></audio>"
        + "and here's a short pause <break time=\"800ms\"/>"
        + "</speak>");
return responseBuilder.build();

JSON

아래의 JSON은 웹훅 응답을 설명합니다.

{
  "payload": {
    "google": {
      "expectUserResponse": true,
      "richResponse": {
        "items": [
          {
            "simpleResponse": {
              "textToSpeech": "<speak>Here are <say-as interpet-as=\"characters\">SSML</say-as> examples.Here is a buzzing fly <audio src=\"https://actions.google.com/sounds/v1/animals/buzzing_fly.ogg\"></audio>and here's a short pause <break time=\"800ms\"/></speak>"
            }
          },
          {
            "simpleResponse": {
              "textToSpeech": "Which response would you like to see next?"
            }
          }
        ]
      }
    }
  }
}

JSON

아래의 JSON은 웹훅 응답을 설명합니다.

{
  "expectUserResponse": true,
  "expectedInputs": [
    {
      "possibleIntents": [
        {
          "intent": "actions.intent.TEXT"
        }
      ],
      "inputPrompt": {
        "richInitialPrompt": {
          "items": [
            {
              "simpleResponse": {
                "textToSpeech": "<speak>Here are <say-as interpet-as=\"characters\">SSML</say-as> examples.Here is a buzzing fly <audio src=\"https://actions.google.com/sounds/v1/animals/buzzing_fly.ogg\"></audio>and here's a short pause <break time=\"800ms\"/></speak>"
              }
            },
            {
              "simpleResponse": {
                "textToSpeech": "Which response would you like to see next?"
              }
            }
          ]
        }
      }
    }
  ]
}

자세한 내용은 SSML 참조 문서를 확인하세요.

사운드 보관함

YouTube 사운드 라이브러리에서 다양하고 짧은 무료 사운드를 제공합니다. 이러한 사운드는 호스팅되므로 SSML에 포함하기만 하면 됩니다.