Hello World Bot|Mastering Microsoft Teams Bots 2.2

2.2 Creating Your First Hello World Bot

Now that your environment is set up, it’s time to write your very first Microsoft Teams bot. This is the moment where abstract architecture becomes something you can interact with — something you built.

In this section, we’ll build a simple bot that listens to messages and responds with “Hello from your bot!” when triggered. It’s not much, but it proves the pipeline works: local code → Teams message → bot response. From here, everything else becomes layering on top of this foundation.

2.2.1 What We’re Building

Our goal is modest: when you type a message to the bot in Microsoft Teams, it should respond with a friendly hello. Along the way, you’ll set up routing, message handling, and a bot endpoint that can receive and respond to incoming events.

2.2.2 Using the Bot Framework SDK

Microsoft’s Bot Framework SDK is the foundation for Teams bots. It handles all the plumbing: receiving messages, parsing activity types, maintaining state, and replying to the user.

You can use either Node.js or .NET. Here we’ll show both side by side so you can choose your preferred stack.

2.2.3 Hello World in Node.js (JavaScript)

Create a new folder and initialize a bot project:


npx @microsoft/generator-botbuilder
# Follow prompts: choose 'Echo Bot', JavaScript, no Azure deploy (for now)
cd my-hello-bot
npm install
npm start
  

The key file is bot.js (or similar), where you'll see this logic:


// Responds to any message
async onMessage(context, next) {
    await context.sendActivity("Hello from your bot!");
    await next();
}
  

2.2.4 Hello World in .NET (C#)

Create a new .NET bot project:


dotnet new echobot -n HelloBot
cd HelloBot
dotnet run
  

Inside Bots\EchoBot.cs, you’ll see the core logic:


public override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
{
    await turnContext.SendActivityAsync(MessageFactory.Text("Hello from your bot!"), cancellationToken);
}
  

2.2.5 Exposing Your Bot via Ngrok

Your bot runs locally, but Microsoft Teams needs a public URL to talk to it. Use ngrok to expose it:

ngrok http 3978

Copy the generated HTTPS URL (e.g. https://abcd1234.ngrok.io) and set it as the Messaging Endpoint in your Azure Bot Registration (e.g. /api/messages).

2.2.6 Testing Your Bot in Teams

  1. In the Azure Portal, go to your Bot Channel Registration.
  2. Make sure Microsoft Teams is enabled as a channel.
  3. Use App Studio or Developer Portal for Teams to create an app package that includes your bot’s App ID.
  4. Sideload it into a team or personal chat and say hello.
  5. If all went well, your bot replies with: Hello from your bot!

You’ve just built a complete feedback loop between Microsoft Teams and your own code. That may sound simple, but you’ve set up authentication, routing, secure tunneling, and Teams channel configuration — all with one success message.

2.2.7 Recap: From Zero to Bot

  • You created a local bot using Node.js or .NET
  • You used Ngrok to expose your endpoint to the internet
  • You registered the bot and tested it in Microsoft Teams

From this foundation, the rest of the journey becomes more exciting — because now your bot can start doing real work.

In the next section, we’ll introduce authentication and identity — critical concepts that allow your bot to access user-specific data, work with Microsoft Graph, and securely interact on behalf of users inside Microsoft Teams.

2025-04-06

Shohei Shimoda

I organized and output what I have learned and know here.