Metadata-Version: 2.4
Name: botas
Version: 0.3.83
Summary: Lightweight library for building Microsoft Bot Service bots - Python
Project-URL: Homepage, https://github.com/rido-min/botas
Project-URL: Repository, https://github.com/rido-min/botas
Project-URL: Issues, https://github.com/rido-min/botas/issues
Author: rido-min
License: MIT
Keywords: bot,bot-framework,chatbot,microsoft-teams
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Communications :: Chat
Requires-Python: >=3.8
Requires-Dist: httpx>=0.27
Requires-Dist: msal>=1.28
Requires-Dist: pydantic>=2.7
Requires-Dist: pyjwt[crypto]>=2.8
Provides-Extra: dev
Requires-Dist: opentelemetry-api>=1.20; extra == 'dev'
Requires-Dist: opentelemetry-sdk>=1.20; extra == 'dev'
Requires-Dist: pdoc>=15; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: respx>=0.21; extra == 'dev'
Requires-Dist: ruff>=0.11; extra == 'dev'
Provides-Extra: observability
Requires-Dist: opentelemetry-api>=1.20; extra == 'observability'
Description-Content-Type: text/markdown

<img src="https://raw.githubusercontent.com/rido-min/botas/main/art/icon-256.png" alt="botas logo" width="96" align="right"/>

# botas

A lightweight, multi-language library for building [Microsoft Teams](https://learn.microsoft.com/en-us/microsoftteams/platform/) bots — this is the **core** Python package.

> For zero-boilerplate FastAPI hosting, see [`botas-fastapi`](https://pypi.org/project/botas-fastapi/).

## Installation

```bash
pip install botas
```

## Quick start (with FastAPI)

```python
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`](https://pypi.org/project/botas-fastapi/) wrapper for a simpler setup:

```python
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

- [Full documentation site](https://rido-min.github.io/botas/)
- [Full feature specification](https://github.com/rido-min/botas/blob/main/specs/README.md)
- [Architecture overview](https://github.com/rido-min/botas/blob/main/specs/architecture.md)
- [Infrastructure setup](https://github.com/rido-min/botas/blob/main/specs/setup.md)

## License

MIT
