Jelajahi di Dialogflow
Klik Continue untuk mengimpor contoh Respons kami di Dialogflow. Kemudian, ikuti langkah-langkah di bawah ini untuk men-deploy dan menguji sampel:
- Masukkan nama agen dan buat agen Dialogflow baru untuk contoh.
- Setelah agen selesai mengimpor, klik Buka agen.
- Dari menu navigasi utama, buka Fulfillment.
- Aktifkan Inline Editor, lalu klik Deploy. Editor berisi kode contoh.
- Dari menu navigasi utama, buka Integrations, lalu klik Google Assistant.
- Di jendela modal yang muncul, aktifkan Perubahan pratinjau otomatis, lalu klik Uji untuk membuka simulator Action.
- Pada simulator, masukkan
Talk to my test app
untuk menguji sampel.
Respons sederhana berbentuk balon chat secara visual dan menggunakan text-to-speech (TTS) atau Bahasa Markup Sintesis Ucapan (SSML) untuk suara.
Teks TTS digunakan sebagai konten balon chat secara default. Jika aspek visual teks tersebut memenuhi kebutuhan, Anda tidak perlu menentukan teks tampilan apa pun untuk balon chat.
Anda juga dapat meninjau panduan desain percakapan kami untuk mempelajari cara menyertakan elemen visual ini dalam Action Anda.
Properti
![](https://developers.google.cn/static/assistant/conversational/images/simple-response.png?authuser=8&hl=id)
Respons sederhana memiliki persyaratan dan properti opsional berikut yang dapat Anda konfigurasi:
- Didukung pada platform dengan kemampuan
actions.capability.AUDIO_OUTPUT
atauactions.capability.SCREEN_OUTPUT
. Batas karakter 640 per balon chat. String yang lebih panjang dari batas akan terpotong pada jeda kata pertama (atau spasi kosong) sebelum 640 karakter.
Konten balon Chat harus berupa subset fonetik atau transkrip lengkap dari output TTS/SSML. Hal ini membantu pengguna memetakan apa yang Anda katakan dan meningkatkan pemahaman dalam berbagai kondisi.
Maksimal dua balon chat per giliran.
Head chat (logo) yang Anda kirimkan ke Google harus berukuran 192x192 piksel dan tidak boleh dianimasi.
![](https://developers.google.cn/static/assistant/conversational/images/smart-display/simple-response.png?authuser=8&hl=id)
Kode contoh
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
Perhatikan bahwa JSON di bawah menjelaskan respons 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
Perhatikan bahwa JSON di bawah menjelaskan respons 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 dan suara
Menggunakan SSML dan suara dalam respons akan memberikan lebih banyak polesan dan meningkatkan pengalaman pengguna. Cuplikan kode berikut menunjukkan cara membuat respons yang menggunakan 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
Perhatikan bahwa JSON di bawah menjelaskan respons 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
Perhatikan bahwa JSON di bawah menjelaskan respons 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?" } } ] } } } ] }
Lihat dokumentasi referensi SSML untuk informasi selengkapnya.
Koleksi suara
Kami menyediakan berbagai suara singkat gratis di koleksi suara kami. Suara ini dihosting untuk Anda, jadi Anda hanya perlu menyertakannya ke dalam SSML.