This project will teach you how to create a free ChatGPT Line Bot!
To integrate a ChatGPT Bot into Line, simply input text into the chat box to start interacting with ChatGPT.
Python FastAPI
: Build the ChatGPT response APIgpt4free
: Free use of OpenAI APILine messaging API channel
: Integrate the ChatGPT APIGithub
: Store the codereplit
: Free deployment of your FastAPICronJob
: Free periodic requests to prevent API interruptions
- Obtain the Line Token:
- Log in to Line Developer
- Create a bot:
- Create a
Provider
-> Click onCreate
- Create a
Channel
-> ChooseCreate a Messaging API channel
- Fill in the required basic information
- After completing, under
Basic Settings
, there is aChannel Secret
-> Click onIssue
to generate it, which will be theLINE_CHANNEL_SECRET
(used later) - Under
Messaging API
, there is aChannel access token
-> Click onIssue
to generate it, which will be theLINE_CHANNEL_ACCESS_TOKEN
(used later)
- Create a
- Fork the Github project:
- Register/log in to GitHub
- Go to ChatGPT-Line-Bot
- Click
Star
to support the developer - Click
Fork
to copy all the code to your own repository
- Deployment (Free Space):
- Go to replit
- Click
Sign Up
and log in directly with your GitHub account and authorize it -> ClickSkip
to skip the initial setup - After entering, click
Create
in the middle of the main page -> A pop-up will appear, click on the top-right cornerImport from Github
- If you haven't joined the GitHub repository, click the link
Connect GitHub to import your private repos.
-> CheckOnly select repositories
-> ChooseChatGPT-Line-Bot
- Go back to step four, and now the
Github URL
can select theChatGPT-Line-Bot
project -> ClickImport from Github
.
-
Environment Variable Configuration
- After completing the previous step, on the left bottom of the project management page in
Replit
, clickTools
-> Click onSecrets
. - After clicking
Got it
on the right, you can add environment variables, you need to add:- Line Channel Secret:
- key:
LINE_CHANNEL_SECRET
- value:
[Obtained from step one]
- key:
- Line Channel Access Token:
- key:
LINE_CHANNEL_ACCESS_TOKEN
- value:
[Obtained from step one]
- key:
- Line Channel Secret:
- After completing the previous step, on the left bottom of the project management page in
-
Start Execution
- Click
Run
at the top - After a successful run, the right-side screen will display
Hello World
, and copy the URL at the top of the screen - Go back to Line Developer, in the
Webhook URL
underMessaging API
, paste the above URL and add/callback
, for example:https://ChatGPT-Line-Bot.jimmylin.repl.co/callback
- Turn on
Use webhook
below - Turn off
Auto-reply messages
below
- Note: If there are no requests within an hour, the program will be interrupted, so this step is necessary
- Click
-
CronJob Scheduled Requests
- Register/log in to cron-job.org
- Go to the panel and select
CREATE CRONJOB
in the upper right - Enter
Title
asChatGPT-Line-Bot
, enter the URL from the previous step, for example:https://ChatGPT-Line-Bot.jimmylin.repl.co/
- Set it to run every
5 minutes
below - Click
CREATE
Go back to Line Developer homepage and click on Join Bot Guide
. Scan the LINE Bot QR code to add it. Congratulations on creating your first LINE Bot! Try talking to it, and it will reply to you!