How silenthg/ccv2bot works
1. What this repo is
- This is a Microsoft Teams command bot built with Node.js and the TeamsFx SDK.
- It is not a traditional web app UI; the user interface lives inside Teams chat messages and Adaptive Cards returned by the bot.
2. Top-level orchestration
- teamsapp.yml is the main lifecycle spec for the app: provisioning, deployment, and local debug.
- teamsapp.local.yml overrides that for local development.
- env/.env.dev and related env files hold environment-specific values that feed both infrastructure and runtime configuration.
3. Runtime entrypoint and bot bootstrap
- src/index.js is the application entrypoint and HTTP/bot host.
- src/internal/initialize.js constructs the bot runtime and registers command handlers.
- src/internal/config.js centralizes runtime configuration from environment values.
- src/teamsBot.js is the extension point for non-command Teams activity handling.
4. Command dispatch model
- The bot is organized as a set of small command handler modules under src/.
- Each handler corresponds to one Teams command, such as:
- createBuild
- createDeployment
- getBuildProgress
- getDeploymentProgress
- getEnvironments
- help
- setupApiToken
- getBotAdmin
- updateBotAdmin
- giveCreateAccess
- src/internal/initialize.js is the main registration boundary where these handlers are wired into the command bot.
5. How a message flows through the system
- A user types a command in Teams.
- Teams routes the message to the bot endpoint hosted by this app.
- The TeamsFx/Bot Framework adapter forwards the activity into the command bot.
- The matching handler executes command-specific logic and returns either plain text or an Adaptive Card response.
6. Adaptive Card presentation layer
- src/adaptiveCards/ contains the card templates used by command responses.
- The cards are rendered dynamically from JSON templates via the Adaptive Cards tooling.
- In this repo, cards are used to present structured command output for commands like help and environment listing.
7. Domain shape of the bot
- This template has been customized beyond the generic “hello world” sample into a command-driven operations bot.
- The handler names indicate the bot likely fronts automation around build/deployment workflows, progress checks, environment discovery, and access/admin setup.
- That means the bot is an orchestration layer over external processes or services, not just a static responder.
8. Azure and hosting boundary
- infra/azure.bicep and infra/azure.parameters.json define the Azure resources needed to host the bot.
- The presence of web.config and .appserviceIgnore suggests the bot is intended to run on Azure App Service.
- infra/botRegistration/azurebot.bicep provisions the Teams/Azure bot registration separately from the app hosting resources.
9. Teams packaging boundary
- appPackage/manifest.json defines how the app appears in Teams, including the supported command list and bot metadata.
- This manifest is the contract between Teams and the bot: it determines what commands users can type and how the app is installed.
10. Local development vs deployed behavior
- The README indicates the app can be run locally and debugged via Teams Toolkit.
- Local behavior is controlled by teamsapp.local.yml, while cloud deployment is controlled by teamsapp.yml and the infra templates.
- This creates a clean split between developer workflow and Azure-hosted runtime.
11. Important architectural boundaries
- Teams manifest boundary: what commands exist and how Teams exposes them.
- Bot runtime boundary: message reception, routing, and response generation.
- Command handler boundary: one file per command, isolating business logic.
- Card/template boundary: presentation JSON separated from handler logic.
- Infrastructure boundary: Azure provisioning and bot registration kept outside application code.
12. What to show in an architecture diagram
- Teams client → Teams platform → bot endpoint in Azure App Service → TeamsFx/Bot Framework adapter → command dispatcher in initialize.js → individual command handler modules → Adaptive Card templates / external services.
- In parallel, show deployment-time flows from teamsapp.yml into infra/*.bicep and appPackage/manifest.json, because those define how the bot is created, registered, and exposed to Teams.
Main entry points: initialize.js Bootstrap · teamsapp.yml App lifecycle · index.js Entry point · .env.dev Env values
Components 26
Runtime
Bot host, bootstrapping, and command dispatch.
- Entry point · Application entrypoint and bot host startup.
src/index.js - Bootstrap · Constructs the bot runtime and registers command handlers.
src/internal/initialize.js - Config · Centralized runtime configuration from environment values.
src/internal/config.js - Teams bot · Non-command Teams activity extension point.
src/teamsBot.js
Commands
One module per Teams command, with command-specific logic.
- Build cmd · Handles createBuild command requests.
src/createBuildCommandHandler.js - Deploy cmd · Handles createDeployment command requests.
src/createDeploymentCommandHandler.js - Build status · Handles build progress lookup.
src/getBuildProgressCommandHandler.js - Deploy status · Handles deployment progress lookup.
src/getDeploymentProgressCommandHandler.js - Environments · Handles environment discovery and listing.
src/getEnvironmentsCommandHandler.js - Help cmd · Handles help output for the bot.
src/helpCommandHandler.js - Token setup · Handles API token setup.
src/setupApiTokenCommandHandler.js - Get admin · Handles bot admin lookup.
src/getBotAdminCommandHandler.js - Update admin · Handles bot admin changes.
src/updateBotAdminCommandHandler.js - Create access · Handles create-access permission changes.
src/giveCreateAccessCommandHandler.js
Cards
Adaptive Card templates used by structured responses.
Deploy
Teams packaging, environment values, and Azure provisioning.
- Manifest · Defines Teams exposure, metadata, and supported commands.
appPackage/manifest.json - App lifecycle · Main provisioning, deployment, and local debug specification.
teamsapp.yml - Local override · Local development override for the lifecycle spec.
teamsapp.local.yml - Env values · Environment-specific configuration consumed by runtime and infrastructure.
env/.env.dev - Azure infra · Primary Azure provisioning template.
infra/azure.bicep - Azure params · Parameters for Azure provisioning.
infra/azure.parameters.json - Bot reg · Provisions the Azure/Teams bot registration.
infra/botRegistration/azurebot.bicep
Other components
- Teams users · People issuing bot commands inside Microsoft Teams.
- Teams platform · Routes chat activities to the registered bot endpoint.
- Bot host · Azure-hosted HTTP endpoint for the bot.
Connections 27
- Teams users → Teams platform: send command · Users type commands in Teams.
- Teams platform → Bot host: route activity · Teams routes the message to the bot endpoint.
- Bot host → Entry point: host · The bot runs as the App Service-hosted Node process.
- Entry point → Config: load config · Startup reads environment-driven configuration.
- Entry point → Bootstrap: bootstrap · Entrypoint builds and starts the bot runtime.
- Entry point → Teams bot: activity hook · Non-command activity handling is attached here.
- Bootstrap → Build cmd: register · Command dispatcher wires the build creation handler.
- Bootstrap → Deploy cmd: register · Command dispatcher wires the deployment creation handler.
- Bootstrap → Build status: register · Command dispatcher wires build progress lookup.
- Bootstrap → Deploy status: register · Command dispatcher wires deployment progress lookup.
- Bootstrap → Environments: register · Command dispatcher wires environment listing.
- Bootstrap → Help cmd: register · Command dispatcher wires help output.
- Bootstrap → Token setup: register · Command dispatcher wires token setup.
- Bootstrap → Get admin: register · Command dispatcher wires admin lookup.
- Bootstrap → Update admin: register · Command dispatcher wires admin updates.
- Bootstrap → Create access: register · Command dispatcher wires create-access changes.
- Help cmd → Help card: render · Help responses use an Adaptive Card template.
- Environments → Env card: render · Environment listing uses an Adaptive Card template.
- App lifecycle → Manifest: package · Lifecycle spec drives the Teams app package and manifest.
- App lifecycle → Azure infra: provision · Lifecycle spec invokes Azure provisioning.
- App lifecycle → Bot reg: register · Lifecycle spec includes bot registration provisioning.
- App lifecycle → Env values: configure · Lifecycle spec consumes environment values.
- Local override → App lifecycle: override · Local settings override the base lifecycle spec.
- Azure infra → Azure params: parametrize · Azure provisioning is driven by parameters.
- Env values → Entry point: runtime env · Environment values feed application startup.
- Env values → Azure infra: infra env · Environment values also feed infrastructure provisioning.
- Manifest → Teams platform: declare bot · Manifest defines how Teams exposes the bot and commands.