תשובות פשוטות (Dialogflow)

אפשרויות נוספות ב-Dialogflow

יש ללחוץ על המשך כדי לייבא את דוגמת התשובות מ-Dialogflow. לאחר מכן, מבצעים את הפעולות הבאות כדי לפרוס את הדוגמה ולבדוק אותה:

  1. צריך להזין שם נציג וליצור נציג חדש ב-Dialogflow לדוגמה.
  2. כשמסיימים לייבא את הנציג, לוחצים על מעבר לנציג.
  3. מתפריט הניווט הראשי, עוברים אל מילוי הזמנה.
  4. מפעילים את עורך מוטבע ולוחצים על פריסה. העורך מכיל את הקוד לדוגמה.
  5. בתפריט הניווט הראשי, נכנסים אל Integrations (שילובים) ולוחצים על Google Assistant.
  6. בחלון החלון הקופץ, מפעילים את האפשרות שינויים בתצוגה מקדימה אוטומטית ולוחצים על בדיקה כדי לפתוח את סימולטור הפעולות.
  7. בסימולטור, מזינים Talk to my test app כדי לבדוק את הטעימה!
המשך

התגובות הפשוטות מופיעות בצורת בועת צ'אט באופן חזותי, ובעזרת המרת טקסט לדיבור (TTS) או המרת טקסט לדיבור (TTS) בשפה (SSML) לצליל.

כברירת מחדל, טקסט TTS משמש כתוכן בועת צ'אט. אם ההיבט החזותי של הטקסט עונה על הצרכים שלכם, לא תצטרכו לציין טקסט לתצוגה לבועת צ'אט.

תוכלו גם לקרוא את ההנחיות לעיצוב שיחה כדי ללמוד איך לשלב את הרכיבים החזותיים האלה בפעולה.

תכונות

איור 1. דוגמה לתשובה פשוטה (סמארטפון)

בתשובות הפשוטות יש את הדרישות הבאות ומאפיינים אופציונליים שאפשר להגדיר:

  • נתמכת בפלטפורמות עם היכולות actions.capability.AUDIO_OUTPUT או actions.capability.SCREEN_OUTPUT.
  • מגבלה של 640 תווים לכל בועת צ'אט. מחרוזות שארוכות מהמגבלה ייקטעו במעבר המילה הראשון (או ברווח לבן) לפני 640 תווים.

  • תוכן בועת הצ'אט חייב להיות קבוצת משנה פונטית או תמליל מלא של פלט TTS/SSML. כך הם יוכלו להבין טוב יותר את מה שאומרים בתנאים שונים.

  • לכל היותר שתי בועות צ'אט בכל תור.

  • כותרת הצ'אט (לוגו) ששולחים ל-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 שמוצג בהמשך מתאר תגובה של תגובה לפעולה מאתר אחר (webhook).

{
  "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 שמוצג בהמשך מתאר תגובה של תגובה לפעולה מאתר אחר (webhook).

{
  "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 שמוצג בהמשך מתאר תגובה של תגובה לפעולה מאתר אחר (webhook).

{
  "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 שמוצג בהמשך מתאר תגובה של תגובה לפעולה מאתר אחר (webhook).

{
  "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.