Skip to main content

Quickstart: Build your first bot

Write a bot that responds to messages in Teams using the Teams SDK. Pick your language below.

tip

If you haven't registered your Teams app yet, start with Quickstart: Register your app โ€” you'll need the credentials before this code can talk to Teams.

Pick your languageโ€‹

If you scaffolded with teams project new typescript, your src/index.ts already looks like this:

import { App } from '@microsoft/teams.apps';

const app = new App();

app.on('message', async ({ send, activity }) => {
await send({ type: 'typing' });
await send(`you said "${activity.text}"`);
});

app.start(process.env.PORT || 3978).catch(console.error);
PartPurpose
new App()Reads credentials from .env automatically
app.on('message', ...)Registers a handler for incoming messages
send({ type: 'typing' })Shows the typing indicator while you build a reply
send(...)Replies in the same conversation
app.start(port)Starts the HTTP server on the given port

Run it:

npm run dev

Continue with the TypeScript guide for events, sending messages, Adaptive Cards, AI, and more.

What's nextโ€‹