Skip to content

OpenAI Chatbot Integration with LINE Messaging API

Notifications You must be signed in to change notification settings

wanyiL/linebot-template-openai

 
 

Repository files navigation

OpenAI Chatbot Integration with LINE Messaging API

This repository contains a Python-based FastAPI application that integrates OpenAI's ChatGPT with the LINE Messaging API.

Overview

The application uses the OpenAI API to generate responses to user messages sent via LINE. The integration is done using FastAPI and the LINE Messaging API.

Prerequisites

To run this application, you will need:

  • Python 3.6 or later
  • An OpenAI account with API key
  • LINE Messaging API Channel with a Channel Secret and Channel Access Token

Installation

  1. Clone this repository:
git clone https://github.com/your-repository.git
  1. Navigate to the project directory:
cd your-repository
  1. Install the required packages:
pip install -r requirements.txt

Configuration

Create a .env file in the project root directory with the following variables:

OPENAI_API_KEY=your_openai_api_key
ChannelSecret=your_line_channel_secret
ChannelAccessToken=your_line_channel_access_token

Replace your_openai_api_key, your_line_channel_secret, and your_line_channel_access_token with your actual OpenAI API key, LINE Channel Secret, and LINE Channel Access Token respectively.

Usage

Run the FastAPI application:

uvicorn main:app --reload

The application will start on http://localhost:8000/.

API Endpoints

  • POST /callback: Handles incoming requests from the LINE Messaging API.

Deploy this on Web Platform

You can choose Heroku or Render

Deploy this on Heroku

Deploy

  • Input Channel Secret and Channel Access Token.
  • Input OpenAI API Key in OPENAI_API_KEY.
  • Remember your heroku, ID

Deploy this on Render.com

Deploy to Render

License

This project is licensed under the Apache License, Version 2.0. For more information, see the LICENSE file.

About

OpenAI Chatbot Integration with LINE Messaging API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 98.1%
  • Procfile 1.9%