Microsoft Teams bots: using the VIDAI Control Plane as the backend¶
Teams bots built on the Bot Framework SDK call an LLM inside their activity handler. Point that call at the control plane and every message the bot posts back into Teams flows through us.
TL;DR (Python — botbuilder-core)¶
from botbuilder.core import ActivityHandler, TurnContext
from openai import OpenAI
client = OpenAI(
base_url="https://your-vidai-server.example.com/v1",
api_key="your-vidai-key",
)
class VidaiBot(ActivityHandler):
async def on_message_activity(self, turn: TurnContext):
resp = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": turn.activity.text}],
)
await turn.send_activity(resp.choices[0].message.content)
TL;DR (JavaScript — botbuilder)¶
const { ActivityHandler } = require("botbuilder");
const OpenAI = require("openai");
const client = new OpenAI({
baseURL: "https://your-vidai-server.example.com/v1",
apiKey: "your-vidai-key",
});
class VidaiBot extends ActivityHandler {
constructor() {
super();
this.onMessage(async (context, next) => {
const resp = await client.chat.completions.create({
model: "gpt-4o-mini",
messages: [{ role: "user", content: context.activity.text }],
});
await context.sendActivity(resp.choices[0].message.content);
await next();
});
}
}
Prerequisites¶
- A Microsoft Teams app registered in Azure Bot Service (or Developer Portal for Teams).
- A Bot Framework-based service (Python or JS) reachable at a public HTTPS endpoint.
- Control plane base URL and an API key from API Keys.
- A model registered on the Models page.
Storing the key¶
Store openai_api_key in Azure Key Vault and mount it into
your bot service's runtime.
Teams AI Library¶
Microsoft's Teams AI Library (an SDK on top of Bot Framework)
uses an OpenAIModel class that takes endpoint + apiKey
directly:
const { OpenAIModel } = require("@microsoft/teams-ai");
const model = new OpenAIModel({
apiKey: "your-vidai-key",
endpoint: "https://your-vidai-server.example.com/v1",
defaultModel: "gpt-4o-mini",
});
Wire that model into your Application and every planner /
prompt runs through the control plane.
Attribution¶
One VIDAI API key per bot service. For enterprise deployments of a single bot into many tenants, mint keys per tenant.
Verify it works¶
@mention the bot in a Teams channel:
The bot posts ok. A row appears on
Request Logs.
If something's off¶
Raise an issue at github.com/vidaiUK/vidai-quickstart/issues with the bot handler code (masking the key) and the failing Teams message. We'll get it sorted.
Where to go next¶
- Client integrations overview
- API Keys
- Chargeback
- Semantic Kernel — the .NET-friendly path if you want higher-level orchestration inside a Teams bot