Lightweight library for building Microsoft Bot Service bots - Python
Project description
botas
A lightweight, multi-language library for building Microsoft Teams bots — this is the core Python package.
For zero-boilerplate FastAPI hosting, see
botas-fastapi.
Installation
pip install botas
Quick start (with FastAPI)
from botas import BotApplication
from botas_fastapi import bot_auth_dependency
from fastapi import Depends, FastAPI, Request
bot = BotApplication()
@bot.on("message")
async def on_message(ctx):
await ctx.send(f"You said: {ctx.activity.text}")
app = FastAPI()
@app.post("/api/messages", dependencies=[Depends(bot_auth_dependency())])
async def messages(request: Request):
body = await request.body()
await bot.process_body(body.decode())
return {}
Or use the higher-level botas-fastapi wrapper for a simpler setup:
from botas_fastapi import BotApp
app = BotApp()
@app.on("message")
async def on_message(ctx):
await ctx.send(f"You said: {ctx.activity.text}")
app.start()
API
BotApplication
The core bot class — web-framework-agnostic.
| Method | Description |
|---|---|
on(type, handler) |
Register a handler for an activity type (also works as a @decorator) |
on_invoke(name, handler) |
Register a handler for an invoke activity by name (also works as a @decorator) |
use(middleware) |
Add a middleware to the turn pipeline (runs in registration order) |
process_body(body) |
Process a raw JSON body string |
Authentication options
BotApplicationOptions fields (also resolved from environment variables):
| Option | Env variable | Description |
|---|---|---|
client_id |
CLIENT_ID |
Azure AD application (bot) ID |
client_secret |
CLIENT_SECRET |
Azure AD client secret |
tenant_id |
TENANT_ID |
Azure AD tenant ID (default: common) |
managed_identity_client_id |
MANAGED_IDENTITY_CLIENT_ID |
Managed identity client ID |
token_factory |
— | Custom async token factory (scope, tenant_id) -> str |
Documentation
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file botas-0.3.31.tar.gz.
File metadata
- Download URL: botas-0.3.31.tar.gz
- Upload date:
- Size: 29.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe051c913fe132c807bfdcc7c86f42b960384f571a0b11a4a3911d8f55fec979
|
|
| MD5 |
34f1598602ff90496a41be8b7f6201e0
|
|
| BLAKE2b-256 |
0275550fe8fab2e142078e0573d783d6c56994febe4235f19457ca94a462e369
|
Provenance
The following attestation bundles were made for botas-0.3.31.tar.gz:
Publisher:
CD.yml on rido-min/botas
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
botas-0.3.31.tar.gz -
Subject digest:
fe051c913fe132c807bfdcc7c86f42b960384f571a0b11a4a3911d8f55fec979 - Sigstore transparency entry: 1376581877
- Sigstore integration time:
-
Permalink:
rido-min/botas@4db4a5bced369c6033bcca01c5c0336b3462469c -
Branch / Tag:
refs/tags/v0.3.31-alpha - Owner: https://github.com/rido-min
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
CD.yml@4db4a5bced369c6033bcca01c5c0336b3462469c -
Trigger Event:
push
-
Statement type:
File details
Details for the file botas-0.3.31-py3-none-any.whl.
File metadata
- Download URL: botas-0.3.31-py3-none-any.whl
- Upload date:
- Size: 26.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76934d2a32f3bb3956808241333ac1e8d6f7063e212c6fd8c2337bf23ad4440a
|
|
| MD5 |
931e8b08ef2d39d9bbe42bf7a47b6188
|
|
| BLAKE2b-256 |
a7579b9d39410531a1630b4618f314b13214a077d4a41e20b2cddd8cfbcd0d54
|
Provenance
The following attestation bundles were made for botas-0.3.31-py3-none-any.whl:
Publisher:
CD.yml on rido-min/botas
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
botas-0.3.31-py3-none-any.whl -
Subject digest:
76934d2a32f3bb3956808241333ac1e8d6f7063e212c6fd8c2337bf23ad4440a - Sigstore transparency entry: 1376581920
- Sigstore integration time:
-
Permalink:
rido-min/botas@4db4a5bced369c6033bcca01c5c0336b3462469c -
Branch / Tag:
refs/tags/v0.3.31-alpha - Owner: https://github.com/rido-min
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
CD.yml@4db4a5bced369c6033bcca01c5c0336b3462469c -
Trigger Event:
push
-
Statement type: