This project is an AI Chat Bot using Amazon Bedrock for LINE (LINE is the popular messaging app in Japan).
It features a serverless chatbot implemented in less code using Bedrock, AWS' generative AI service, and Step Functions, a workflow service.
First, make Anthropic's Claude available through Amazon Bedrock's "Model access" in the AWS Management Console. See the documentation for details.
This project are provisioned by the AWS Cloud Development Kit (CDK). If you have not installed the CDK, first install it by referring to the documents.
Then, since it is a LINE bot, it is necessary to create a channel used the LINE Messaging API. You can create that channel after creating a provider in the LINE Developers console.
In the LINE Developers console, create a provider and create a channel used the Messaging API.
Enable "Webhook URL" in LINE Developer console.
Channel secret can be issued in "Basic settings" tab.
Channel access token can be issued in "Messaging API" tab.
Note both values.
Set values in the home directory ~/.cdk.json
with the channel secret and access token of LINE issued in previous step as parameters. If the file does not exist, create it.
It will work even if you set the secret in cdk.json
in the repository, but it is safer to set it in a file in your home directory because there is a risk of accidentally pushing the secret and having it published.
Add "line-bot-with-amazon-bedrock": {...}
the following:
{
// :
// (snip)
// :
"line-bot-with-amazon-bedrock": {
"secret": "...(channel secret)...",
"accessToken": "...(channel access token)..."
}
}
git clone https://github.com/msysh/aws-sample-line-bot-with-amazon-bedrock.git
cd line-bot-with-amazon-bedrock
cdk deploy --all
You can get an API Gateway URL endpoint from cdk deploy output.
LineBotWithAmazonBedrock.ApiGatewayEndpointXXX = https://xxxxx.execute-api.us-east-1.amazonaws.com/prod/
Configure the endpoint URL as Webhook URL in LINE Developers console.
Use the QR code displayed in the "Messaging API" tab in the LINE Developers console to add a friend and have a conversation!
If you want to customize the prompt, go to the AWS Management Console and change the parameter /line-bot-with-amazon-bedrock/prompt-template
in the Systems Manager Parameter Store.
The first {}
will be replaced by the conversation history and the second {}
by the message from user.
If you want to delete an AWS resource, execute the following command:
cdk destroy --all
Prompt engineering allows for chatbots with a variety of characters.
MIT