page_type | products | languages | technologies | title | description | extensions | urlFragment | copilot | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sample |
|
|
|
Microsoft Teams Hello World Bot - Copilot Agent Optimized |
A comprehensive Microsoft Teams hello world bot sample optimized for GitHub Copilot Agent development, featuring advanced bot functionality, tabs, and messaging extensions with modern JavaScript patterns. |
|
officedev-microsoft-teams-samples-app-hello-world-nodejs-copilot-optimized |
|
A comprehensive Microsoft Teams bot sample that showcases fundamental Teams platform features including tabs, bots, and messaging extensions. This sample has been optimized for GitHub Copilot Agent development with enhanced code structure, comprehensive documentation, and modern development patterns.
This sample is part of the official Microsoft Teams Samples repository: https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/app-hello-world/nodejs
For more Teams samples and documentation, visit the main repository: https://github.com/OfficeDev/Microsoft-Teams-Samples
- Tabs
- Bots
- Messaging Extensions
Please find below demo manifest which is deployed on Microsoft Azure and you can try it yourself by uploading the app package (.zip file link below) to your teams and/or as a personal app. (Uploading must be enabled for your tenant, see steps here).
Microsoft Teams hello world sample app: Manifest
-
Microsoft Teams is installed and you have an account (not a guest account)
-
To test locally, NodeJS must be installed on your development machine (version 16.14.2 or higher)
-
dev tunnel or ngrok latest version or equivalent tunneling solution
-
M365 developer account or access to a Teams account with the appropriate permissions to install an app.
The simplest way to run this sample in Teams is to use Microsoft 365 Agents Toolkit for Visual Studio Code.
- Ensure you have downloaded and installed Visual Studio Code
- Install the Microsoft 365 Agents Toolkit extension
- Select File > Open Folder in VS Code and choose this samples directory from the repo
- Using the extension, sign in with your Microsoft 365 account where you have permissions to upload custom apps
- Select Debug > Start Debugging or F5 to run the app in a Teams web client.
- In the browser that launches, select the Add button to install the app to Teams.
If you do not have permission to upload custom apps (uploading), Microsoft 365 Agents Toolkit will recommend creating and using a Microsoft 365 Developer Program account - a free program to get your own dev environment sandbox that includes Teams.
This sample is optimized for GitHub Copilot Agent development with:
- Teams-first development patterns prioritized over generic Bot Framework
- Enhanced discoverability through project structure and documentation
- Copilot-specific guidance in
.github/copilot-instructions.md
- Development patterns and examples in
.copilot/
directory
- Use Copilot prompts for Teams bot development
- Reference
.copilot/prompts/hello-world.md
for common patterns - Follow Teams-specific coding standards in development guidelines
- Echo Bot Functionality - Intelligent message processing with context awareness
- Teams Tabs - Static and configurable tab experiences
- Messaging Extensions - Search-based extensions with dynamic card generation
- State Management - Conversation state with proper error handling
- Teams Activity Handler - Full Teams platform integration
- Enhanced Code Discoverability - Semantic naming and modular architecture
- Comprehensive JSDoc - Detailed inline documentation for better AI understanding
- Modular File Structure - Clean separation of concerns for easy code navigation
- Agent-Friendly Patterns - Code patterns optimized for AI assistance and generation
- Copilot Prompts - Pre-configured prompts and instructions in
.copilot/
directory
src/
├── app.js # Main application entry point
├── bot.js # Bot functionality and handlers
├── tabs.js # Teams tab management and routing
├── message-extension.js # Messaging extension components
├── static/ # Static assets and content
└── views/ # HTML templates for tabs
.copilot/ # Copilot Agent optimization
├── prompts/ # Copilot-specific prompts
│ └── hello-world.md # Development guidance and patterns
└── instructions/ # Development guidelines
├── development-guidelines.md # Coding standards and best practices
└── agent-patterns.md # Advanced agent development patterns
.github/ # GitHub integration
└── copilot-instructions.md # Teams-first development guidance
- Microsoft Teams account (not guest account)
- Node.js 16.14.2+ for development
- Dev tunnel or ngrok for local testing
- M365 developer account or Teams account with app upload permissions
- Microsoft 365 Agents Toolkit for VS Code (recommended)
This sample is optimized for GitHub Copilot Agent Mode with:
.github/copilot-instructions.md
- Teams-first development guidance.copilot/
directory - Agent-specific prompts and patterns- Comprehensive JSDoc - Rich context for AI assistance
- Teams-specific patterns - Prioritized over generic Bot Framework
Note these instructions are for running the sample on your local machine, the tunnelling solution is required because the Teams service needs to call into the bot.
-
In Azure portal, create a Azure Bot resource
-
Ensure that you've enabled the Teams Channel
-
While registering the bot, use
https://<your_tunnel_domain>/api/messages
as the messaging endpoint.NOTE: When you create your bot you will create an App ID and App password - make sure you keep these for later.
-
Run ngrok - point to port 3333
ngrok http 3333 --host-header="localhost:3333"
Alternatively, you can also use the
dev tunnels
. Please follow Create and host a dev tunnel and host the tunnel with anonymous user access command as shown below:devtunnel host -p 3333 --allow-anonymous
-
Clone the repository
git clone https://github.com/OfficeDev/Microsoft-Teams-Samples.git
-
In a terminal, navigate to
samples/app-hello-world/nodejs
-
Install modules
npm install
-
Update the
custom-environment-variables
configuration for the bot to use theMicrosoftAppId
andMicrosoftAppPassword
,BaseUrl
with application base url. -
Update the
default
configuration for the bot to use theappId
andappPassword
. -
Run your app
npm start
-
This step is specific to Teams.
- Edit the
manifest.json
contained in theapp-hello-world/nodejs/appManifest
folder to replace your Microsoft App Id (that was created when you registered your bot earlier) everywhere you see the place holder string<<Your Microsoft App Id>>
(depending on the scenario the Microsoft App Id may occur multiple times in themanifest.json
) - Edit the
manifest.json
forconfigurationUrl
insideconfigurableTabs
andvalidDomains
. Replace{{domain-name}}
with base Url domain. E.g. if you are using ngrok it would behttps://1234.ngrok-free.app
then your domain-name will be1234.ngrok-free.app
and if you are using dev tunnels then your domain will be like:12345.devtunnels.ms
.
Note: If you want to test your app across multi hub like: Outlook/Office.com, please update the
manifest.json
in theapp-hello-world/nodejs/appManifest_Hub
folder with the required values.- Zip up the contents of the
app-hello-world/nodejs/appManifest
folder to create amanifest.zip
orapp-hello-world/nodejs/appManifest_Hub
folder into aManifest_Hub.zip
.(Make sure that zip file does not contains any subfolder otherwise you will get error while uploading your .zip package) - Upload the
manifest.zip
to Teams (In Teams Apps/Manage your apps click "Upload an app". Browse to and Open the .zip file. At the next dialog, click the Add button.) - Add the app to personal/team/groupChat scope (Supported scopes)
- Edit the
This app has a default landing capability that determines whether the opening scope is set to the Bot or a static tab. Without configuring this, Microsoft Teams defaults to landing on the bot in desktop clients and tab in mobile clients.
To set the Bot as the default landing capability, configure the 'staticTabs' section in the manifest as follows:
"staticTabs": [
{
"entityId": "conversations",
"scopes": [
"personal"
]
},
{
"entityId": "com.contoso.helloworld.hellotab",
"name": "Hello Tab",
"contentUrl": "https://${{BOT_DOMAIN}}/hello",
"scopes": [
"personal"
]
}
],
To set the Tab as the default landing capability, configure the 'staticTabs' section in the manifest as follows:
"staticTabs": [
{
"entityId": "com.contoso.helloworld.hellotab",
"name": "Hello Tab",
"contentUrl": "https://${{BOT_DOMAIN}}/hello",
"scopes": [
"personal"
]
},
{
"entityId": "conversations",
"scopes": [
"personal"
]
}
],
Note: If you are facing any issue in your app, please uncomment this line and put your debugger for local debug.
Install App:
Hello World Bot:
Hello Wrold Tab:
-
To view your app in Outlook on the web.
-
Go to Outlook on the weband sign in using your dev tenant account.
On the side bar, select More Apps. Your uploaded app title appears among your installed apps
Select your app icon to launch and preview your app running in Outlook on the web
Note: Similarly, you can test your application in the Outlook desktop app as well.
-
To preview your app running in Office on the web.
-
Log into office.com with test tenant credentials
Select the Apps icon on the side bar. Your uploaded app title appears among your installed apps
Select your app icon to launch your app in Office on the web
Note: Similarly, you can test your application in the Office 365 desktop app as well.
To learn more about deploying a bot to Azure, see Deploy your bot to Azure for a complete list of deployment instructions.