Metadata-Version: 2.4
Name: botas-fastapi
Version: 0.3.78
Summary: FastAPI integration for botas – zero-boilerplate Bot Service bot hosting
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,fastapi,microsoft-teams
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: FastAPI
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: botas==0.3.78
Requires-Dist: fastapi>=0.111
Requires-Dist: uvicorn[standard]>=0.30
Provides-Extra: dev
Requires-Dist: httpx>=0.27; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff>=0.11; extra == 'dev'
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-fastapi

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

> Wraps [`botas`](https://pypi.org/project/botas/) with a FastAPI server for zero-boilerplate bot hosting.

## Installation

```bash
pip install botas-fastapi
```

## Quick start

```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()
```

## Manual FastAPI wiring

For full control over routes, middleware, and server lifecycle:

```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 {}
```

## API

### `BotApp`

High-level wrapper that composes a `BotApplication` with a FastAPI + Uvicorn server.

| 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 |
| `start()` | Start the FastAPI/Uvicorn server |

### Options

`BotApp` accepts `BotApplicationOptions` plus these additional keyword arguments:

| Option | Default | Description |
|---|---|---|
| `port` | `3978` (or `PORT` env) | HTTP listen port |
| `path` | `/api/messages` | Endpoint path for incoming activities |
| `auth` | Auto (enabled when `client_id` is set) | Enable/disable JWT auth middleware |

### Authentication options

Inherited from `BotApplicationOptions` — see the [`botas` package README](https://pypi.org/project/botas/) for the full list of authentication options and environment variables.

## 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
