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

Page updated May 2, 2024

Set up Amplify Interactions

AWS Amplify Interactions enables AI-powered chatbots in your web or mobile apps. You can use Interactions to configure your backend chatbot provider and to integrate a chatbot UI into your app with just a single line of code.

Interactions with AWS

AWS Amplify supports Amazon Lex as the default chatbots service. Amazon Lex supports creating conversational bots with the same deep learning technologies that power Amazon Alexa.

Setup AWS LexV2 bot

You can create an Amazon Lex V2 chatbot in Amazon Lex console. To create your bot, follow the steps shown in Amazon Lex V2 Developer Guide.

Amazon Lex intents page with a bot called 'BookTripNew', showing a list of two created intents 'BookCar' and 'FallbackIntent' that your users want to accomplish like booking a car

Update your IAM Policy

Amazon Lex service requires an IAM policy in order to use the interactions APIs (remember to replace the template with real value):

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["lex:RecognizeText", "lex:RecognizeUtterance"],
"Resource": "arn:aws:lex:<your-app-region>:<your-account-id>:bot-alias/<your-bot-id>/<your-bot-alias-id>"
}
]
}

Configure your frontend

Add the aws-amplify and interactions package to your project:

Terminal
npm add --save @aws-amplify/interactions aws-amplify

Make sure that the @aws-amplify/interactions package has the same version number as the aws-amplify package in your package.json file.

Configure Amplify

Import and load the configuration file in your app. It's recommended you add the Amplify configuration step to your app's root entry point. For example, App.js (Expo) or index.js (React Native CLI).

src/index.js
import { Amplify } from 'aws-amplify';
import outputs from '../amplify_outputs.json';
Amplify.configure(outputs);
Amplify.configure({
...Amplify.getConfig(),
Interactions: {
LexV2: {
'<your-bot-name>': {
aliasId: '<your-bot-alias-id>',
botId: '<your-bot-id>',
localeId: '<your-bot-locale-id>',
region: '<your-bot-region>'
}
}
}
});

Make sure you call Amplify.configure as early as possible in your application’s life-cycle. A missing configuration or NoCredentials error is thrown if Amplify.configure has not been called before other Amplify JavaScript APIs. Review the Library Not Configured Troubleshooting guide for possible causes of this issue.