Messaging API overview - Requests are sent over HTTPS in JSON. The communication flow between a bot server and the LINE Platform is as follows:
- A user sends a message to a LINE Official Account.
- The LINE Platform sends a webhook event to the webhook URL of the bot server.
- The bot server checks the webhook event and responds to the user through the LINE Platform. (with your coding/logic)
What's LINE Messaging API can do?
- Send reply messages
- Send messages at any time
- Send different message types
- Text message
- Sticker message
- Image message
- Video message
- Audio message
- Location message
- Imagemap message
- Template message
- Flex Message
- Get content sent by users
- Get user profiles
- Join group chats
- Use rich menus
- Use beacons
- Use account link
- Get the number of sent messages
Run following command in your working directory
virtualenv venv
where, venv
is your virtual environment name
Run following command in your working directory
source venv/bin/activate
There's 3 required packages:
- line-bot-sdk
- fastapi
- uvicorn
- python-dotenv
To install latest version, run pip
command to install
pip install line-bot-sdk fastapi uvicorn python-dotenv
Or, you can install with the requirements.txt
pip install -r requirements.txt
Create file .env
and put your token inside.
ACCESS_TOKEN=<Your dhannel access token>
CHANNEL_SECRET=<Your Channel secret>
Using following command to run FastAPI on port 8000:
uvicorn main:app --port 8000 --reload
The reload
flag is for reload everytime that file made change.