Quickstart
Get started with Teams SDK quickly using the Teams CLI.
Set up a new project​
Prerequisites​
- Python v3.12 or higher. Install or upgrade from python.org/downloads.
Instructions​
Install the Teams CLI​
Install teams globally:
npm install -g @microsoft/teams.cli@preview
teams --version
The Teams CLI is the command-line tool for scaffolding, registering, and managing Teams apps. It's currently in Preview.
Creating Your First Agent​
Let's begin by creating a simple echo agent that responds to messages. Run:
teams project new python quote-agent --template echo
This command:
- Creates a new directory called
quote-agent. - Bootstraps the echo agent template files into it under
quote-agent/src. - Creates your agent's manifest files, including a
manifest.jsonfile and placeholder icons in thequote-agent/appPackagedirectory. The Teams app manifest is required for sideloading the app into Teams.
The
echotemplate creates a basic agent that repeats back any message it receives - perfect for learning the fundamentals.
Running your agent​
Navigate to your new agent's directory:
cd quote-agent
Start the development server:
python src/main.py
In the console, you should see a similar output:
[INFO] @teams/app Successfully initialized all plugins
[INFO] @teams/app.HttpPlugin Starting HTTP server on port 3978
INFO: Started server process [6436]
INFO: Waiting for application startup.
[INFO] @teams/app.HttpPlugin listening on port 3978 🚀
[INFO] @teams/app Teams app started successfully
INFO: Application startup complete..
INFO: Uvicorn running on http://0.0.0.0:3978 (Press CTRL+C to quit)
When the application starts, you'll see:
- An HTTP server starting up (on port
3978). This is the main server which handles incoming requests and serves the agent application.
Add to an Existing Project​
If you already have a project and want to add Teams support, install the SDK directly:
pip install microsoft-teams-apps
Then initialize the Teams app with your existing server:
import asyncio
import uvicorn
from fastapi import FastAPI
from microsoft_teams.apps import App, FastAPIAdapter
# Your existing FastAPI app
my_fastapi = FastAPI()
# Wrap your app in an adapter and create the Teams app
adapter = FastAPIAdapter(app=my_fastapi)
app = App(http_server_adapter=adapter)
@app.on_message
async def handle_message(ctx):
await ctx.send(f"You said: {ctx.activity.text}")
async def main():
await app.initialize() # Register the Teams endpoint (does not start a server)
# Start your server as usual
config = uvicorn.Config(app=my_fastapi, host="0.0.0.0", port=3978)
server = uvicorn.Server(config)
await server.serve()
asyncio.run(main())
app.initialize() registers the Teams endpoint on your server without starting a new one — you keep full control of your server lifecycle.
See the HTTP Server guide for full details on adapters and custom server setups.
Next steps​
After creating and running your first agent, read about the code basics to better understand its components and structure.
Otherwise, if you want to run your agent in Teams, you can check out the Running in Teams guide.