Skip to main content

Lark Channel SDK for Python

lark-channel-sdk is a Python package for building Feishu and Lark conversational bots. It provides FeishuChannel as the main entry point for event listening, message normalization, policy control, outbound messaging, media handling, card callbacks, and streaming replies.

Install

pip install lark-channel-sdk

Minimal Example

import asyncio
import os

from lark_channel import FeishuChannel

channel = FeishuChannel(
    app_id=os.environ["LARK_APP_ID"],
    app_secret=os.environ["LARK_APP_SECRET"],
)


async def on_message(msg):
    await channel.send(
        msg.chat_id,
        {"markdown": f"received: {msg.content_text}"},
        {"reply_to": msg.message_id},
    )


channel.on("message", on_message)
asyncio.run(channel.connect())

Documentation

Migration from lark_oapi.channel

Install the standalone package and update the import path:

pip install lark-channel-sdk
from lark_channel import FeishuChannel

lark-channel-sdk can be installed alongside lark-oapi. Use lark-channel-sdk for Channel bot workflows and keep using lark-oapi when your application needs the full OpenAPI SDK surface.

See the migration guide for import mapping, runtime compatibility notes, and a migration checklist.

Meeting Channel

Agents that perceive and respond inside a live meeting — captions, meeting chat, participants, shared documents. Two entry points, one session type.

# The bot joins as a real participant and can speak into the meeting.
channel.on("meetingInvited", lambda inv: channel.join_meeting(inv.meeting_no))

# Or follow the meeting a user is already in, without joining it.
session = await channel.follow_my_meeting(user_open_id="ou_...")

session.on("transcript", lambda e: notes.append(e.text))
session.on("chat", on_chat)
await session.send_message("noted")   # joined sessions only
await session.leave()

Three things to know before you start:

  • The bot's own in-meeting messages come back to it. So a meeting-chat handler needs if event.self_echo: return, or the bot spends the meeting replying to itself at network speed.
  • Disconnecting does not take the bot out of the meeting. disconnect() closes the event channel; the bot stays a participant, which is what makes reconnects safe. A process that is really exiting should leave() each session first.
  • follow_my_meeting reads what every participant says, and the bot is not in the participant list. Two more things: the user_open_id you pass has to be somebody you have already established is the requester — the SDK receives a string and cannot check that for you — and what the user grants in one go is every scope your app applied for, not just the meeting read. See Security configuration.

For event ordering, how captions settle from interim to final, how many sessions can run at once, and what to check when nothing arrives, see Meeting channel.

Security Mode

SecurityConfig defaults to compatibility mode so existing bots continue to run during migration. For production rollout, start with audit mode and then move to strict mode after reviewing audit events:

from lark_channel import FeishuChannel, SecurityConfig

channel = FeishuChannel(
    app_id="cli_xxx",
    app_secret="***",
    security=SecurityConfig(mode="audit"),
)

See Security configuration for strict-mode behavior and webhook compatibility switches.

Local Development

pip install -e ".[test]"
python -m pytest

License

This distribution is licensed as MIT AND BSD-3-Clause: project code is licensed under the MIT License as described in LICENSE, and vendored third-party code is documented in THIRD_PARTY_NOTICES.md.

Metadata

Release files for lark-channel-sdk 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lark-channel-sdk 1.4.0
File Size Uploaded Provenance
lark_channel_sdk-1.4.0.tar.gz 454.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for lark-channel-sdk 1.4.0
File Interpreter ABI Platform
lark_channel_sdk-1.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.1 MB

Release files / lark_channel_sdk-1.4.0.tar.gz

Download URL lark_channel_sdk-1.4.0.tar.gz
Size 454.3 kB
Tags Source
SHA-256 checksum
How to use checksums
603f97ead821e22749e34fca1e52539cc86858bb9f2679c613923182a504958d
BLAKE2b-256 checksum
How to use checksums
79d48a71bedd95cf852ae2e368851b11ebc7015810995e99907c3cc2e547979d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / lark_channel_sdk-1.4.0-py3-none-any.whl

Download URL lark_channel_sdk-1.4.0-py3-none-any.whl
Size 633.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5466fc5e92b6405795e3cd8ea7ed570a83cab2bc095ac446f786f2a34ee58eb5
BLAKE2b-256 checksum
How to use checksums
fe28954d53bf93913c25bd28b6755284df135e0704ee71a7ffae236e3ea3c279
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for lark-channel-sdk 1.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page