Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions packages/cli/templates/python/ai/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Python Teams AI Bot

This is a minimal Microsoft Teams ai bot template using [microsoft-teams](https://github.com/microsoft/teams.py).
This is a minimal Microsoft Teams ai agent template using [microsoft-teams](https://github.com/microsoft/teams.py).

## Structure

Expand All @@ -11,7 +11,4 @@ This is a minimal Microsoft Teams ai bot template using [microsoft-teams](https:
## Getting Started

1. Install [uv](https://github.com/astral-sh/uv).
2. Run:
```
uv venv && uv sync && uv run src/main.py
```
2. Run `uv run start`
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[project]
name = "ai-bot"
name = "{{ toKebabCase name }}"
version = "0.1.0"
description = "A Microsoft Teams AI bot using teams.py and OpenAI"
authors = [{ name = "Your Name", email = "[email protected]" }]
Expand All @@ -12,4 +12,20 @@ dependencies = [
"microsoft.teams.ai",
"microsoft.teams.openai",
"microsoft-teams-devtools"
]
]

[dependency-groups]
dev = [
"pyright>=1.1.406",
]

[project.scripts]
start = "src.main:main"
typecheck = "pyright.cli:entrypoint"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
packages = ["src"]
6 changes: 5 additions & 1 deletion packages/cli/templates/python/ai/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,9 @@ async def handle_message(ctx):
await ctx.send(result.response.content)


if __name__ == "__main__":
def main():
asyncio.run(app.start())


if __name__ == "__main__":
main()
5 changes: 1 addition & 4 deletions packages/cli/templates/python/echo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,4 @@ This is a minimal Microsoft Teams echo bot template using [microsoft-teams](http
## Getting Started

1. Install [uv](https://github.com/astral-sh/uv).
2. Run:
```
uv venv && uv sync && uv run src/main.py
```
2. Run `uv run start`
16 changes: 16 additions & 0 deletions packages/cli/templates/python/echo/pyproject.toml.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,19 @@ dependencies = [
"microsoft-teams-apps",
"microsoft-teams-devtools"
]

[dependency-groups]
dev = [
"pyright>=1.1.406",
]

[project.scripts]
start = "src.main:main"
typecheck = "pyright.cli:entrypoint"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
packages = ["src"]
7 changes: 5 additions & 2 deletions packages/cli/templates/python/echo/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
app = App(plugins=[DevToolsPlugin()])



@app.on_message_pattern(re.compile(r"hello|hi|greetings"))
async def handle_greeting(ctx: ActivityContext[MessageActivity]) -> None:
"""Handle greeting messages."""
Expand All @@ -26,5 +25,9 @@ async def handle_message(ctx: ActivityContext[MessageActivity]):
await ctx.send(f"You said '{ctx.activity.text}'")


if __name__ == "__main__":
def main():
asyncio.run(app.start())


if __name__ == "__main__":
main()
14 changes: 14 additions & 0 deletions packages/cli/templates/python/graph/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Python Teams Graph Bot

This is a minimal Microsoft Teams graph bot template using [microsoft-teams](https://github.com/microsoft/teams.py).

## Structure

- `src/main.py`: Main application code for the Teams bot.
- `pyproject.toml`: Project dependencies and metadata (use [uv](https://github.com/astral-sh/uv) for dependency management).
- `apppackage/`: Teams app manifest and related files.

## Getting Started

1. Install [uv](https://github.com/astral-sh/uv).
2. Run `uv run start`
16 changes: 16 additions & 0 deletions packages/cli/templates/python/graph/pyproject.toml.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,19 @@ dependencies = [
"microsoft-teams-graph",
"dotenv"
]

[dependency-groups]
dev = [
"pyright>=1.1.406",
]

[project.scripts]
start = "src.main:main"
typecheck = "pyright.cli:entrypoint"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
packages = ["src"]
35 changes: 22 additions & 13 deletions packages/cli/templates/python/graph/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# Create app with OAuth connection
app = App(default_connection_name=os.getenv("CONNECTION_NAME", "graph"))


@app.on_message_pattern("signout")
async def handle_signout_command(ctx: ActivityContext[MessageActivity]):
"""Handle sign-out command."""
Expand All @@ -37,7 +38,7 @@ async def handle_profile_command(ctx: ActivityContext[MessageActivity]):
graph = ctx.user_graph
# Fetch user profile
if graph:
me = await graph.me.get()
me = await graph.me.get()

if me:
profile_info = (
Expand All @@ -52,28 +53,36 @@ async def handle_profile_command(ctx: ActivityContext[MessageActivity]):
else:
await ctx.send("❌ Could not retrieve your profile information.")


@app.on_message
async def handle_default_message(ctx: ActivityContext[MessageActivity]):
"""Handle default message - trigger signin."""
if ctx.is_signed_in:
await ctx.send("✅ You are already signed in!\n\n"
"You can now use these commands:\n\n"
"• **profile** - View your profile\n\n"
"• **signout** - Sign out when done"
await ctx.send(
"✅ You are already signed in!\n\n"
"You can now use these commands:\n\n"
"• **profile** - View your profile\n\n"
"• **signout** - Sign out when done"
)
else:
await ctx.send("🔐 Please sign in to access Microsoft Graph...")
await ctx.sign_in()


@app.event("sign_in")
async def handle_sign_in_event(event: SignInEvent):
"""Handle successful sign-in events."""
await event.activity_ctx.send(
"✅ **Successfully signed in!**\n\n"
"You can now use these commands:\n\n"
"• **profile** - View your profile\n\n"
"• **signout** - Sign out when done"
)
"""Handle successful sign-in events."""
await event.activity_ctx.send(
"✅ **Successfully signed in!**\n\n"
"You can now use these commands:\n\n"
"• **profile** - View your profile\n\n"
"• **signout** - Sign out when done"
)


def main():
asyncio.run(app.start())


if __name__ == "__main__":
asyncio.run(app.start())
main()