الردود البسيطة (Dialogflow)

الاستكشاف في Dialogflow

انقر على متابعة لاستيراد نموذج الردود في Dialogflow. بعد ذلك، اتّبِع الخطوات أدناه لنشر النموذج واختباره:

  1. أدخِل اسم وكيل وأنشِئ وكيل Dialogflow جديدًا للنموذج.
  2. بعد الانتهاء من استيراد الوكيل، انقر على الانتقال إلى الوكيل.
  3. من قائمة التنقّل الرئيسية، انتقِل إلى توصيل الطلبات.
  4. فعِّل المحرِّر المضمّن، ثم انقر على نشر. ويتضمّن المحرِّر نموذج الرمز.
  5. من قائمة التنقّل الرئيسية، انتقِل إلى عمليات الدمج، ثم انقر على مساعد Google.
  6. في النافذة المشروطة التي تظهر، فعِّل تغييرات المعاينة التلقائية وانقر على اختبار لفتح محاكي الإجراءات.
  7. في المحاكي، أدخِل Talk to my test app لاختبار العيّنة.
متابعة

تأخذ الردود البسيطة شكل فقاعة محادثة بشكل مرئي وتستخدم أداة تحويل النص إلى كلام (TTS) أو لغة ترميز تركيب الكلام (SSML) للصوت.

يُستخدم نص تحويل النص إلى كلام (TTS) بشكل افتراضي لمحتوى فقاعة المحادثة. إذا كان الجانب المرئي من هذا النص يلبي احتياجاتك، فلن تحتاج إلى تحديد أي نص معروض في فقاعة محادثة.

يمكنك أيضًا مراجعة إرشادات تصميم المحادثات للتعرّف على كيفية دمج هذه العناصر المرئية في الإجراء الخاص بك.

أماكن إقامة

الشكل 1. مثال للاستجابة البسيطة (هاتف ذكي)

للاستجابات البسيطة المتطلبات التالية والخصائص الاختيارية التي يمكنك إعدادها:

  • وتكون متوافقة مع مساحات العرض المزوّدة بالإمكانات actions.capability.AUDIO_OUTPUT أو actions.capability.SCREEN_OUTPUT.
  • عدد الأحرف المسموح به لكل فقاعة محادثة هو 640 حرفًا. يتم اقتطاع السلاسل الأطول من الحد عند فاصل الكلمات الأول (أو المسافة البيضاء) قبل 640 حرفًا.

  • يجب أن يكون محتوى فقاعة المحادثة مجموعة فرعية صوتية أو نصًا كاملاً من مخرجات TTS/SSML. يساعد هذا المستخدمين على تحديد ما تقوله ويزيد من الفهم في ظروف مختلفة.

  • فقاعتا محادثة على الأكثر في كل منعطف.

  • يجب أن يكون حجم رأس المحادثة (الشعار) الذي ترسله إلى Google بحجم 192×192 بكسل، ولا يمكن أن يكون متحركة.

الشكل 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 المرجعية للحصول على مزيد من المعلومات.

مكتبة الملفات الصوتية

نقدّم مجموعة متنوعة من المحتوى الصوتي القصير والمجاني في مكتبة الملفات الصوتية. تتم استضافة هذه الأصوات لك، لذا كل ما عليك فعله هو تضمينها في SSML الخاص بك.