Skip to content

kj-huang/line-english-teacher

Repository files navigation

Line English Teacher

This is a document for setting up the project environment for the LINE chatbot that uses OpenAI to respond to user queries.

Prerequisites

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

Step 1: Set up .env file

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

Step 2: Install dependencies

Navigate to the project directory Install the Node.js dependencies: npm install

Step 3: Install ffmpeg

Install ffmpeg using your operating system's package manager. For example, on Ubuntu, run sudo apt install ffmpeg

Step 4: Set up LINE API keys

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

Step 5: Set up OpenAI API key

Go to the OpenAI API page and create a new API key.

Copy the API key and add it to the .env file

Step 6: Set up AWS instance

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

Step 7: Set up the container

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>

Step 8: Set up LINE API webhook

Go to the LINE Developers Console Click on the channel you created earlier Set the webhook URL to http:///webhook

Step 9: Test your LINE bot!

Open your LINE account, add your LINE bot as a friend

Send a message to your bot and verify that it responds correctly

Conclusion

Congratulations! You have set up a LINE chatbot that uses OpenAI to respond to user queries.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published