پاسخ‌های ساده (Dialogflow)

کاوش در Dialogflow

برای وارد کردن نمونه «پاسخ‌های» ما در Dialogflow، روی ادامه کلیک کنید. سپس، مراحل زیر را برای استقرار و آزمایش نمونه دنبال کنید:

  1. نام عاملی را وارد کنید و عامل Dialogflow جدیدی برای نمونه ایجاد کنید.
  2. پس‌از اینکه وارد کردن عامل تمام شد، روی رفتن به عامل کلیک کنید.
  3. از منو پیمایش اصلی، به انجام سفارش بروید.
  4. ویرایشگر درون‌خطی را فعال کنید، سپس روی استقرار کلیک کنید. ویرایشگر حاوی کد نمونه است.
  5. از منو پیمایش اصلی، به ادغام‌ها بروید، سپس روی دستیار Google کلیک کنید.
  6. در پنجره مقیدی که ظاهر می‌شود، پیش‌نمایش خودکار تغییرات را فعال کنید و روی آزمایش کلیک کنید تا شبیه‌ساز «کنش‌ها» باز شود.
  7. در شبیه‌ساز، Talk to my test app را برای آزمایش نمونه وارد کنید!
ادامه

پاسخ‌های ساده به‌صورت حبابک گپ نمایش داده می‌شوند و از نوشتار به گفتار (TTS) یا «زبان نشانه‌گذاری ترکیب گفتار» (SSML) برای صدا استفاده می‌کنند.

نوشتار «نوشتار به گفتار» به‌طور پیش‌فرض به‌عنوان محتوای حبابک گپ استفاده می‌شود. اگر جنبه بصری آن نوشتار نیازهایتان را برآورده می‌کند، لازم نیست هیچ نوشتار نمایشی برای حبابک گپ مشخص کنید.

همچنین می‌توانید رهنمودهای طراحی مکالمه ما را مرور کنید تا با نحوه گنجاندن این عناصر دیداری در «کنش» خود آشنا شوید.

مشخصات

شکل ۱. نمونه پاسخ ساده (تلفن هوشمند)

پاسخ‌های ساده الزامات و ویژگی‌های اختیاری زیر را دارند که می‌توانید پیکربندی کنید:

  • در سطوح دارای قابلیت‌های actions.capability.AUDIO_OUTPUT یا actions.capability.SCREEN_OUTPUT پشتیبانی می‌شود.
  • حد نویسه برای هر حبابک گپ ۶۴۰ است. رشته‌های طولانی‌تر از حد مجاز در اولین شکست کلمه (یا فضای خالی) قبل‌از ۶۴۰ نویسه کوتاه می‌شوند.

  • محتوای حبابک گپ باید زیرمجموعه آوایی یا ترانویسی کامل خروجی TTS/SSML باشد. این کار به کاربران کمک می‌کند آنچه را می‌گویید ترسیم کنند و درک مطلب را در شرایط مختلف افزایش می‌دهد.

  • حداکثر دو حبابک گپ در هر نوبت.

  • سر گپ (نشان‌واره) که به Google ارسال می‌کنید باید ۱۹۲×۱۹۲ پیکسل باشد و نمی‌تواند پویانمایی‌شده باشد.

شکل ۲. نمونه پاسخ ساده (نمایشگر هوشمند)

کدگذاری نمونه

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?`,
  }));
});

جاوا

@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?`,
}));

جاوا

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?');
});

جاوا

@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?');

جاوا

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 مراجعه کنید.

کتابخانه صدا

ما انواع صداهای کوتاه و رایگان را در کتابخانه صدا خود ارائه می‌دهیم. این صداها برای شما میزبانی می‌شوند، بنابراین تنها کاری که باید انجام دهید این است که آن‌ها را در SSML خود بگنجانید.