Name:
interface
Value:
Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

Choose your framework/language

Gen1 DocsLegacy

Page updated Mar 26, 2026

ボットと対話する

AWS will end support for Amazon Lex V1 on September 15, 2025,, and is no longer accepting any new users as of March 31. The guidance is to migrate to Amazon Lex V2.

ボットにメッセージを送信する

send() コマンドでテキストメッセージをチャットボットバックエンドに送信できます。このメソッドはチャットボットの応答を含むプロミスを返します。

src/App.tsx
import { Interactions } from '@aws-amplify/interactions';
const userInput = "I want to reserve a hotel for tonight";
// Provide a bot name and user input
const response = await Interactions.send({
botName: "TheBotName",
message: userInput
});
// Log chatbot response
console.log(response.message);

チャット終了メッセージを表示する

onComplete() メソッドを使用して、セッションが正常に終了したときにエラーをキャッチするか、チャットボットの確認を処理する関数を登録できます。

src/App.tsx
import { Interactions } from '@aws-amplify/interactions';
Interactions.onComplete({
botName: "TheBotName",
callback: (error?: Error, completion?: {[key: string]: any}) => {
if (error) {
alert('bot conversation failed');
} else if (completion) {
console.debug('done: ' + JSON.stringify(completion, null, 2));
alert('Trip booked. Thank you! What would you like to do next?');
}
}
});