Skip to main content

FastAPI integration for botas – zero-boilerplate Bot Service bot hosting

Project description

botas logo

botas-fastapi

A lightweight, multi-language library for building Microsoft Teams bots — this is the FastAPI integration package.

Wraps botas with a FastAPI server for zero-boilerplate bot hosting.

Installation

pip install botas-fastapi

Quick start

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:

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


Download files

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

Source Distribution

botas_fastapi-0.3.33.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

botas_fastapi-0.3.33-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file botas_fastapi-0.3.33.tar.gz.

File metadata

  • Download URL: botas_fastapi-0.3.33.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for botas_fastapi-0.3.33.tar.gz
Algorithm Hash digest
SHA256 be4fb23581eff28b20811b8d517312d803a092847763555a23d7c17e2a824d50
MD5 7e320cfe11f676f2663f8d82169e89f0
BLAKE2b-256 21ec0082d87edb8b037864de68e66bd5cc8be042864bd1df0ddbe7bfaa1620f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for botas_fastapi-0.3.33.tar.gz:

Publisher: CD.yml on rido-min/botas

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file botas_fastapi-0.3.33-py3-none-any.whl.

File metadata

  • Download URL: botas_fastapi-0.3.33-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for botas_fastapi-0.3.33-py3-none-any.whl
Algorithm Hash digest
SHA256 7db47798d21b175db2936b172fb34fb0813462d1c0858500a57309c0f1118b22
MD5 aa6bf191e53d741e5594e8c7bde135cf
BLAKE2b-256 eaa8d7602d462249e627c5db628f4e91a2430ea97ab119806005f4337cf8fb7d

See more details on using hashes here.

Provenance

The following attestation bundles were made for botas_fastapi-0.3.33-py3-none-any.whl:

Publisher: CD.yml on rido-min/botas

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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