LINE Messaging API enables bot development for LINE, the dominant messaging platform in Japan, Thailand, and Taiwan with 196M+ monthly users. Official SDKs exist for Python and Node.js. Primary documentation is in Japanese — English docs are complete but may lag Japanese versions.
pip install line-bot-sdkVerified import paths — ran on the pinned version, not inferred.
Minimal LINE bot webhook handler using linebot.v3 SDK with Flask.
Always call handler.handle(body, signature) and catch InvalidSignatureError. Abort 400 on failure.
Register LINE middleware before any body parser middleware on the webhook route
Use push messages (push_message API) for delayed or async responses instead of reply tokens
Process webhook events asynchronously. Return 200 immediately, handle events in background.
Channel secret → WebhookHandler constructor. Channel access token → Configuration/MessagingApi.
Track opt-out webhook events to maintain your own block list and avoid unnecessary push API calls.
Use https://api-data.line.me/v2/bot/message/{messageId}/content for binary content retrievalEnsure all necessary Python packages are installed in the environment where the script is executed. This can be done using `pip install <package_name>` for individual packages or `pip install -r requirements.txt` if a `requirements.txt` file is used to list dependencies.
Ensure the 'Channel Secret' in your bot application exactly matches the one in the LINE Developers Console, and use the raw request body without any modification (e.g., pretty-printing JSON) for signature validation with UTF-8 encoding.
Verify that the 'Channel Access Token' in your code is correct and currently valid in the LINE Developers Console. If it's a short-lived token, ensure it hasn't expired, and if it's been reissued or revoked, obtain a new valid token.
Ensure the 'reply_token' is used immediately after receiving the event and has not been used before, as reply tokens are single-use and time-sensitive. Also, verify that the message objects in your request adhere to the LINE Messaging API specifications.
Install the library using pip: `pip install line-bot-sdk`. Confirm that your script is being executed within the Python environment where the package was installed.
Update your imports and code to use the `linebot.v3` modules and classes as specified in the deprecation warning, adapting your code to the new API structure.