Skip to main content

linebot-sdk-python wrapper.

Project description


linebot-sdk-python wrapper.


pip install pylinebot


from pylinebot import LINE, Tracer

bot = LINE(

Example (Echo-bot)

from flask import Flask, request
from pylinebot import LINE, Tracer

def receive_message(bot, event):
    reply_token = event.reply_token

    message = event.message
    message_type = message.type

    if message_type == 'text':
        message_text = message.text
        bot.send_text_message(reply_token, message_text)

DEBUG = True

app = Flask(__name__)

bot = LINE(

tracer = Tracer(bot, debug=DEBUG)
tracer.add_event('message', receive_message)

@app.route("/", methods=['POST'])
def hello():
    signature = request.headers['X-Line-Signature']
    body = request.get_data(as_text=True)
    tracer.trace(body, signature)
    return 'OK'

if __name__ == '__main__':'', port=3000, debug=DEBUG)

Send Message

  • text
bot.send_text_message(reply_token, text)
  • image
bot.send_image_message(reply_token, 'https://xxx.xxxx/xxxx.jpg')
  • video
video_data = {
    'content_url': 'https://xxx.xxxx/xxxx.mp4',
    'preview_url': 'https://xxx.xxxx/xxxx.jpg'
bot.send_video_message(reply_token, video_data)
  • audio
audio_data = {
    'content_url': 'https://xxx.xxxx/xxxx.mp3',
    'duration': 1000
bot.send_audio_message(reply_token, audio_data)
  • location
location_data = {
    'title': 'title',
    'address': 'adress_name',
    'latitude': 0,
    'longitude': 0
bot.send_location_message(reply_token, location_data)
  • sticker
sticker_data = {
    'package_id': 1,
    'sticker_id': 1
bot.send_sticker_message(reply_token, sticker_data)
  • flex
flex_data = {
    'flex': flex_content,
    'alt_text': 'Flex Message'
bot.send_flex_message(reply_token, flex_data)

replay, push, other

Default send_type='reply'


  • reply
  • push
  • broadcast
  • narrowcast
  • multicast
bot.send_text_message(to, text, send_type='push')

Quick reply

action_list = [
        'type': 'message',
        'label': 'aaaa',
        'text': 'これ送信'
        'type': 'camera',
        'label': 'かめら',
        'type': 'cameraRoll',
        'label': 'かめらろーる',
        'type': 'location',
        'label': 'ろけーしょん',
        'type': 'postback',
        'label': 'ぽすとばっく',
        'data': 'test_postback'
        'type': 'datetimepicker',
        'label': 'でーとぴっく',
        'data': 'test_datepick',
        'mode': 'date',
        'initial': '2020-05-15',
        'max': '2020-05-31',
        'min': '2020-05-01'
bot.send_text_message(reply_token, 'text', quick_reply=quick_reply)

Send multiple messages

The max count of messages that can be sent at one time is 5.

# 2 text message
bot.send_text_message(reply_token, 'text', 'text')
# 5 text message
bot.send_text_message(reply_token, 'text', 'text', 'text', 'text', 'text')
# Error
bot.send_text_message(reply_token, 'text', 'text', 'text', 'text', 'text', 'text')

Send various messages at once.

message_list = [
    bot.create_video_message('https://xxx.xxxx/xxxx.mp4', 'https://xxx.xxxx/xxxx.jpg')
bot.send_message(reply_token, message_list)

Save message content

Save image, video, and audio data sent by users.

bot.save_content_from_message_id(message_id, file_name)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pylinebot-1.0.1.tar.gz (5.7 kB view hashes)

Uploaded Source

Built Distribution

pylinebot-1.0.1-py3-none-any.whl (10.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page