สำรวจใน Dialogflow
คลิกต่อไปเพื่อนำเข้าตัวอย่างการตอบกลับใน Dialogflow จากนั้นทำตามขั้นตอนด้านล่างเพื่อทำให้ใช้งานได้และทดสอบตัวอย่าง
- ป้อนชื่อตัวแทนและสร้าง Agent ใหม่ใน Dialogflow สำหรับตัวอย่าง
- หลังจากนำเข้า Agent เสร็จแล้ว ให้คลิกไปที่ Agent
- จากเมนูการนำทางหลัก ให้ไปที่การดำเนินการคำสั่งซื้อ
- เปิดใช้ตัวแก้ไขในบรรทัด แล้วคลิกทำให้ใช้งานได้ ซึ่งตัวแก้ไขจะมีโค้ดตัวอย่าง
- จากเมนูการนําทางหลัก ให้ไปที่ Integrations แล้วคลิก Google Assistant
- ในหน้าต่างโมดัลที่ปรากฏ ให้เปิดใช้แสดงตัวอย่างการเปลี่ยนแปลงอัตโนมัติ และคลิกทดสอบเพื่อเปิดเครื่องจำลองการดำเนินการ
- ในเครื่องจำลอง ให้ป้อน
Talk to my test app
เพื่อทดสอบตัวอย่าง
คำตอบง่ายๆ จะอยู่ในรูปแบบของลูกโป่งแชทในรูปแบบภาพ และจะใช้การอ่านออกเสียงข้อความ (TTS) หรือ Speech Synthesis Markup Language (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