สํารวจใน Dialogflow
คลิกต่อไปเพื่อนําเข้าตัวอย่างการตอบกลับใน Dialogflow จากนั้นทําตามขั้นตอนด้านล่างเพื่อทําให้ใช้งานได้และทดสอบตัวอย่าง
- ป้อนชื่อตัวแทนแล้วสร้าง Agent ใหม่ใน Dialogflow สําหรับตัวอย่าง
- หลังจากตัวแทนนําเข้าเสร็จแล้ว ให้คลิกไปที่ตัวแทน
- จากเมนูการนําทางหลัก ให้ไปที่การดําเนินการ
- เปิดใช้เครื่องมือแก้ไขในบรรทัด แล้วคลิกทําให้ใช้งานได้ ตัวแก้ไขมีโค้ดตัวอย่างอยู่
- จากเมนูการนําทางหลัก ให้ไปที่การผสานรวม แล้วคลิก Google Assistant
- ในหน้าต่างโมดัลที่ปรากฏขึ้น ให้เปิดใช้แสดงตัวอย่างการเปลี่ยนแปลงอัตโนมัติ แล้วคลิกทดสอบเพื่อเปิดเครื่องจําลองการดําเนินการ
- ในเครื่องจําลอง ให้ป้อน
Talk to my test app
เพื่อทดสอบตัวอย่าง
คําตอบง่ายๆ จะอยู่ในรูปแบบลูกโป่งแชทและใช้การอ่านออกเสียงข้อความ (TTS) หรือภาษามาร์กอัปสังเคราะห์เสียง (SSML) กับเสียง
ข้อความ TTS จะใช้เป็นเนื้อหาลูกโป่งแชทโดยค่าเริ่มต้น หากแง่มุมของข้อความนั้นตรงกับความต้องการของคุณ คุณไม่จําเป็นต้องระบุข้อความการแสดงผลสําหรับลูกโป่งแชท
และอ่านหลักเกณฑ์การออกแบบการสนทนาเพื่อดูวิธีรวมองค์ประกอบภาพเหล่านี้ไว้ในการดําเนินการของคุณ
พร็อพเพอร์ตี้

การตอบกลับแบบง่ายมีข้อกําหนดและพร็อพเพอร์ตี้ที่ไม่บังคับต่อไปนี้ซึ่งคุณกําหนดค่าได้
- รองรับในแพลตฟอร์มที่มีความสามารถ
actions.capability.AUDIO_OUTPUT
หรือactions.capability.SCREEN_OUTPUT
จํานวนอักขระในแชทสูงสุด 640 อักขระ สตริงที่ยาวกว่าขีดจํากัดจะถูกตัดออกที่ตัวแบ่งคําแรก (หรือช่องว่าง) ก่อนอักขระ 640 ตัว
เนื้อหาลูกโป่งแชทต้องเป็นชุดย่อยของการออกเสียงหรือข้อความถอดเสียงของเอาต์พุต TTS/SSML ที่สมบูรณ์ ซึ่งจะช่วยให้ผู้ใช้อธิบายสิ่งที่คุณพูดและเพิ่มความเข้าใจในเงื่อนไขต่างๆ ได้
บับเบิลแชทสูงสุด 2 รายการต่อครั้ง
ส่วนหัวแชท (โลโก้) ที่คุณส่งไปยัง Google ต้องมีขนาด 192x192 พิกเซล และต้องไม่เป็นภาพเคลื่อนไหว

รหัสตัวอย่าง
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