This is a document for setting up the project environment for the LINE chatbot that uses OpenAI to respond to user queries.
Before getting started, make sure you have the following:
- A GitHub account
- Docker installed on your localhost
- Node.js installed on your localhost
- LINE developer account API keys
- OpenAI API key
- AWS instance with Docker and Git installed
Create a new file called .env
in the project directory.
Add the following environment variables to the .env
file:
LINE_BOT_CHANNEL_ID="" #LINE Bot Channel ID
LINE_CHANNEL_ACCESS_TOKEN="" #LINE Channel Access Token
LINE_CHANNEL_SECRET="" #LINE Channel Secret
MY_ACCOUNT="" #Your LINE account ID
OPENAI_API_KEY="" #OpenAI API key
WEB_HOST="" #Web host URL, used for Line get audio file
Navigate to the project directory Install the Node.js dependencies: npm install
Install ffmpeg using your operating system's package manager. For example, on Ubuntu, run sudo apt install ffmpeg
Go to the LINE Developers Console. Create a new LINE Messaging API channel
Copy the CHANNEL_SECRET
and CHANNEL_ACCESS_TOKEN
values and add them to the .env
file
Go to the OpenAI API page and create a new API key.
Copy the API key and add it to the .env
file
Set up an AWS instance with Docker and Git installed Set up GitHub secrets for the AWS instance in GitHub Action:
AWS_PROD_HOST: the public DNS of your AWS instance
AWS_USERNAME: the username used to log in to your AWS instance (usually ubuntu)
AWS_PROD_PEM: the contents of your AWS key pair file
Navigate to the project directory
Build the Docker image: docker build -t <image-name> .
Run the Docker container: docker run -p 80:80 -d --name <container-name> <image-name>
Go to the LINE Developers Console Click on the channel you created earlier Set the webhook URL to http:///webhook
Open your LINE account, add your LINE bot as a friend
Send a message to your bot and verify that it responds correctly
Congratulations! You have set up a LINE chatbot that uses OpenAI to respond to user queries.