ステップ 6: ボットを使用する - Amazon Lex V1

Amazon Lex V2 を使用している場合は、代わりに Amazon Lex V2 ガイドを参照してください。

 

Amazon Lex V1 を使用している場合は、ボットを Amazon Lex V2 にアップグレードすることをお勧めします。V1 には新機能を追加されませんので、すべての新しいボットには V2 を使用することを強くお勧めします。

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

ステップ 6: ボットを使用する

デモの目的で、顧客およびエージェントとしてボットにインプットを提供します。両者を区別するために、顧客からの質問には「Customer:」で始まり、エージェントから提供された回答は「Agent:」で始まります。提案された入力候補のメニューから選ぶことができます。

index.html を開いてウェブアプリケーションを実行すると、次の画像のようにボットとの対話が行われます。


                コールセンターのボットとの 2 つの会話例。1 つ目の例では、カスタマーが Amazon SageMaker とは何か、また Amazon Lex の代わりに Amazon Polly をいつ使用すべきかを尋ねています。2 つ目の例では、Amazon Kendra がこの 2 つの質問に対するよくある質問の回答を検索しています。

「index.html 」ファイル内の pushChat() 機能について説明します。

var endConversationStatement = "Customer: I have no more questions. Thank you." // If the agent has to send a message, start the message with 'Agent' var inputText = document.getElementById('input'); if (inputText && inputText.value && inputText.value.trim().length > 0 && inputText.value[0]=='Agent') { showMessage(inputText.value, 'agentRequest','conversation'); inputText.value = ""; } // If the customer has to send a message, start the message with 'Customer' if(inputText && inputText.value && inputText.value.trim().length > 0 && inputText.value[0]=='Customer') { // disable input to show we're sending it var input = inputText.value.trim(); inputText.value = '...'; inputText.locked = true; customerInput = input.substring(2); // Send it to the Lex runtime var params = { botAlias: '$LATEST', botName: 'KendraTestBot', inputText: customerInput, userId: lexUserId, sessionAttributes: sessionAttributes }; showMessage(input, 'customerRequest', 'conversation'); if(input== endConversationStatement){ showMessage('Conversation Ended.','conversationEndRequest','conversation'); } lexruntime.postText(params, function(err, data) { if (err) { console.log(err, err.stack); showMessage('Error: ' + err.message + ' (see console for details)', 'lexError', 'conversation1') } if (data &&input!=endConversationStatement) { // capture the sessionAttributes for the next cycle sessionAttributes = data.sessionAttributes; showMessage(data, 'lexResponse', 'conversation1'); } // re-enable input inputText.value = ''; inputText.locked = false; }); } // we always cancel form submission return false;

顧客として入力すると、Amazon Lex ランタイム API が Amazon Lex に送信します。

showMessage(daText, senderRequest, displayWindow) 機能は、エージェントと顧客との会話をチャットウィンドウに表示します。Amazon Kendra によって提案された回答は、隣接するウィンドウに表示されます。顧客が「“I have no more questions. Thank you.”」と言った時点で会話は終了します

注意: Amazon Kendra のインデックスは、ご使用にならないときは削除してください。