Giter Site home page Giter Site logo

chatgpt-line-bot's Introduction

ChatGPT Line Bot

This project will teach you how to create a free ChatGPT Line Bot!

Introduction

To integrate a ChatGPT Bot into Line, simply input text into the chat box to start interacting with ChatGPT.

Tools and Features

  • Python FastAPI: Build the ChatGPT response API
  • gpt4free: Free use of OpenAI API
  • Line messaging API channel: Integrate the ChatGPT API
  • Github: Store the code
  • replit: Free deployment of your FastAPI
  • CronJob: Free periodic requests to prevent API interruptions

Installation Steps

Getting the Token

  1. Obtain the Line Token:
    1. Log in to Line Developer
    2. Create a bot:
      1. Create a Provider -> Click on Create
      2. Create a Channel -> Choose Create a Messaging API channel
      3. Fill in the required basic information
      4. After completing, under Basic Settings, there is a Channel Secret -> Click on Issue to generate it, which will be the LINE_CHANNEL_SECRET (used later)
      5. Under Messaging API, there is a Channel access token -> Click on Issue to generate it, which will be the LINE_CHANNEL_ACCESS_TOKEN (used later)

Project Setup

  1. Fork the Github project:
    1. Register/log in to GitHub
    2. Go to ChatGPT-Line-Bot
    3. Click Star to support the developer
    4. Click Fork to copy all the code to your own repository
  2. Deployment (Free Space):
    1. Go to replit
    2. Click Sign Up and log in directly with your GitHub account and authorize it -> Click Skip to skip the initial setup
    3. After entering, click Create in the middle of the main page -> A pop-up will appear, click on the top-right corner Import from Github
    4. If you haven't joined the GitHub repository, click the link Connect GitHub to import your private repos. -> Check Only select repositories -> Choose ChatGPT-Line-Bot
    5. Go back to step four, and now the Github URL can select the ChatGPT-Line-Bot project -> Click Import from Github.

Project Execution

  1. Environment Variable Configuration

    1. After completing the previous step, on the left bottom of the project management page in Replit, click Tools -> Click on Secrets.
    2. After clicking Got it on the right, you can add environment variables, you need to add:
      1. Line Channel Secret:
        • key: LINE_CHANNEL_SECRET
        • value: [Obtained from step one]
      2. Line Channel Access Token:
        • key: LINE_CHANNEL_ACCESS_TOKEN
        • value: [Obtained from step one]
  2. Start Execution

    1. Click Run at the top
    2. After a successful run, the right-side screen will display Hello World, and copy the URL at the top of the screen
    3. Go back to Line Developer, in the Webhook URL under Messaging API, paste the above URL and add /callback, for example: https://ChatGPT-Line-Bot.jimmylin.repl.co/callback
    4. Turn on Use webhook below
    5. 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
  3. CronJob Scheduled Requests

    1. Register/log in to cron-job.org
    2. Go to the panel and select CREATE CRONJOB in the upper right
    3. Enter Title as ChatGPT-Line-Bot, enter the URL from the previous step, for example: https://ChatGPT-Line-Bot.jimmylin.repl.co/
    4. Set it to run every 5 minutes below
    5. Click CREATE

Connect to Service and Line Bot

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!


References

Line_Bot_Tutorial

ChatGPT-Line-Bot

chatgpt-line-bot's People

Contributors

lin-jun-xiang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.