Skip to content

Commit

Permalink
fix: update C# bot app template for Test Tool (#10538)
Browse files Browse the repository at this point in the history
  • Loading branch information
qinezh committed Dec 19, 2023
1 parent af88d77 commit 8183980
Show file tree
Hide file tree
Showing 31 changed files with 173 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,26 @@ Before running or debugging your bot, please follow these steps to setup your ow
> . ./Create-Assistant.ps1 -OPENAI_API_KEY xxxxxx
```
1. The above command will output the properties of the new created assistant, including the ID like "id: asst_xxx..."
{{#enableTestToolByDefault}}
1. Fill in both OpenAI API Key and the created Assistant ID into `appsettings.TestTool.json`
```
"OpenAI": {
"ApiKey": "<your-openai-api-key>",
"AssistantId": "<your-openai-assistant-id>"
}
```

**If you already have an Assistant created**

1. Fill in both OpenAI API Key and the created Assistant ID into `appsettings.TestTool.json`
```
"OpenAI": {
"ApiKey": "<your-openai-api-key>",
"AssistantId": "<your-openai-assistant-id>"
}
```
{{/enableTestToolByDefault}}
{{^enableTestToolByDefault}}
1. Fill in both OpenAI API Key and the created Assistant ID into `env/.env.local.user`
```
SECRET_OPENAI_API_KEY=<your-openai-api-key>
Expand All @@ -42,16 +62,23 @@ Before running or debugging your bot, please follow these steps to setup your ow
SECRET_OPENAI_API_KEY=<your-openai-api-key>
SECRET_OPENAI_ASSISTANT_ID=<your-openai-assistant-id>
```
{{/enableTestToolByDefault}}

### Run Teams Bot locally

{{#enableTestToolByDefault}}
1. Press F5, or select the Debug > Start Debugging menu in Visual Studio
1. In Teams App Test Tool from the launched browser, type and send anything to your bot to trigger a response
{{/enableTestToolByDefault}}
{{^enableTestToolByDefault}}
1. In the debug dropdown menu, select Dev Tunnels > Create A Tunnel (set authentication type to Public) or select an existing public dev tunnel
1. Right-click your project and select Teams Toolkit > Prepare Teams App Dependencies
1. If prompted, sign in with a Microsoft 365 account for the Teams organization you want
to install the app to
1. Press F5, or select the Debug > Start Debugging menu in Visual Studio
1. In the launched browser, select the Add button to load the app in Teams
1. In the chat bar, type and send anything to your bot to trigger a response
{{/enableTestToolByDefault}}

## Extend the AI Assistant Bot template with more AI capabilities

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"launchUrl": "http://localhost:56150",
"applicationUrl": "http://localhost:5130",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "TestTool"
"ASPNETCORE_ENVIRONMENT": "TestTool",
"TEAMSFX_NOTIFICATION_STORE_FILENAME": ".notification.testtoolstore.json"
},
"hotReloadProfile": "aspnetcore"
},
Expand All @@ -37,7 +38,8 @@
"launchUrl": "http://localhost:56150",
"applicationUrl": "http://localhost:5130",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "TestTool"
"ASPNETCORE_ENVIRONMENT": "TestTool",
"TEAMSFX_NOTIFICATION_STORE_FILENAME": ".notification.testtoolstore.json"
},
"hotReloadProfile": "aspnetcore"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"AllowedHosts": "*",
"BOT_ID": "",
"BOT_PASSWORD": "",
"TEAMSFX_NOTIFICATION_STORE_FILENAME": ".notification.testtoolstore.json",
"OpenAI": {
"ApiKey": "",
"AssistantId": ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,25 @@ The app template is built using the Teams AI library, which provides the capabil
>
> - [Azure OpenAI](https://aka.ms/oai/access) resource or an account with [OpenAI](https://platform.openai.com).

{{#enableTestToolByDefault}}
1. Fill in your OpenAI API Key or Azure OpenAI settings in `appsettings.TestTool.json`
```
# If using OpenAI
"OpenAI": {
"ApiKey": "<your-openai-api-key>"
},

# If using Azure OpenAI
"Azure": {
"OpenAIApiKey": "<your-azure-openai-api-key>",
"OpenAIEndpoint": "<your-azure-openai-endpoint>"
}
```

2. Press F5, or select the Debug > Start Debugging menu in Visual Studio
3. In Teams App Test Tool from the launched browser, type and send anything to your bot to trigger a response
{{/enableTestToolByDefault}}
{{^enableTestToolByDefault}}
1. Fill in your OpenAI API Key or Azure OpenAI settings in `env/.env.local.user`
```
# If using OpenAI
Expand All @@ -28,6 +47,7 @@ to install the app to
5. Press F5, or select the Debug > Start Debugging menu in Visual Studio
6. In the launched browser, select the Add button to load the app in Teams
7. In the chat bar, type and send anything to your bot to trigger a response
{{/enableTestToolByDefault}}

## Extend the AI Chat Bot template with more AI capabilities

Expand Down
6 changes: 4 additions & 2 deletions templates/csharp/ai-bot/Properties/launchSettings.json.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"launchUrl": "http://localhost:56150",
"applicationUrl": "http://localhost:5130",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "TestTool"
"ASPNETCORE_ENVIRONMENT": "TestTool",
"TEAMSFX_NOTIFICATION_STORE_FILENAME": ".notification.testtoolstore.json"
},
"hotReloadProfile": "aspnetcore"
},
Expand All @@ -37,7 +38,8 @@
"launchUrl": "http://localhost:56150",
"applicationUrl": "http://localhost:5130",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "TestTool"
"ASPNETCORE_ENVIRONMENT": "TestTool",
"TEAMSFX_NOTIFICATION_STORE_FILENAME": ".notification.testtoolstore.json"
},
"hotReloadProfile": "aspnetcore"
},
Expand Down
1 change: 0 additions & 1 deletion templates/csharp/ai-bot/appsettings.TestTool.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"AllowedHosts": "*",
"BOT_ID": "",
"BOT_PASSWORD": "",
"TEAMSFX_NOTIFICATION_STORE_FILENAME": ".notification.testtoolstore.json",
"OpenAI": {
"ApiKey": ""
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@

## Quick Start

{{#enableTestToolByDefault}}
1. Press F5, or select the Debug > Start Debugging menu in Visual Studio
2. In Teams App Test Tool from the launched browser, type and send "helloWorld" to your app to trigger a response
{{/enableTestToolByDefault}}
{{^enableTestToolByDefault}}
1. In the debug dropdown menu, select Dev Tunnels > Create A Tunnel (set authentication type to Public) or select an existing public dev tunnel
2. Right-click your project and select Teams Toolkit > Prepare Teams App Dependencies
3. If prompted, sign in with a Microsoft 365 account for the Teams organization you want
to install the app to
4. Press F5, or select the Debug > Start Debugging menu in Visual Studio
5. In the launched browser, select the Add button to load the app in Teams
6. In the chat bar, type and send "helloWorld" to your app to trigger a response
{{/enableTestToolByDefault}}

## Learn more

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"launchUrl": "http://localhost:56150",
"applicationUrl": "http://localhost:5130",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "TestTool"
"ASPNETCORE_ENVIRONMENT": "TestTool",
"TEAMSFX_NOTIFICATION_STORE_FILENAME": ".notification.testtoolstore.json"
},
"hotReloadProfile": "aspnetcore"
},
Expand All @@ -37,7 +38,8 @@
"launchUrl": "http://localhost:56150",
"applicationUrl": "http://localhost:5130",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "TestTool"
"ASPNETCORE_ENVIRONMENT": "TestTool",
"TEAMSFX_NOTIFICATION_STORE_FILENAME": ".notification.testtoolstore.json"
},
"hotReloadProfile": "aspnetcore"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@
},
"AllowedHosts": "*",
"BOT_ID": "",
"BOT_PASSWORD": "",
"TEAMSFX_NOTIFICATION_STORE_FILENAME": ".notification.testtoolstore.json"
"BOT_PASSWORD": ""
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
# Welcome to Teams Toolkit!

## Quick Start

{{#enableTestToolByDefault}}
1. Press F5, or select the Debug > Start Debugging menu in Visual Studio
2. In Teams App Test Tool from the launched browser, type and send anything to your bot to trigger a response
{{/enableTestToolByDefault}}
{{^enableTestToolByDefault}}
1. In the debug dropdown menu, select Dev Tunnels > Create A Tunnel (set authentication type to Public) or select an existing public dev tunnel
2. Right-click your project and select Teams Toolkit > Prepare Teams App Dependencies
3. If prompted, sign in with a Microsoft 365 account for the Teams organization you want
to install the app to
4. Press F5, or select the Debug > Start Debugging menu in Visual Studio
5. In the launched browser, select the Add button to load the app in Teams
6. In the chat bar, type and send anything to your bot to trigger a response
{{/enableTestToolByDefault}}

## Learn more

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"launchUrl": "http://localhost:56150",
"applicationUrl": "http://localhost:5130",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "TestTool"
"ASPNETCORE_ENVIRONMENT": "TestTool",
"TEAMSFX_NOTIFICATION_STORE_FILENAME": ".notification.testtoolstore.json"
},
"hotReloadProfile": "aspnetcore"
},
Expand All @@ -37,7 +38,8 @@
"launchUrl": "http://localhost:56150",
"applicationUrl": "http://localhost:5130",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "TestTool"
"ASPNETCORE_ENVIRONMENT": "TestTool",
"TEAMSFX_NOTIFICATION_STORE_FILENAME": ".notification.testtoolstore.json"
},
"hotReloadProfile": "aspnetcore"
},
Expand Down
3 changes: 1 addition & 2 deletions templates/csharp/default-bot/appsettings.TestTool.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@
},
"AllowedHosts": "*",
"BOT_ID": "",
"BOT_PASSWORD": "",
"TEAMSFX_NOTIFICATION_STORE_FILENAME": ".notification.testtoolstore.json"
"BOT_PASSWORD": ""
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

## Quick Start

{{#enableTestToolByDefault}}
1. Press F5, or select the Debug > Start Debugging menu in Visual Studio
2. Teams App Test Tool will be opened in the launched browser
3. [If you selected http trigger] Open Windows PowerShell and post a HTTP request to trigger
the notification(replace <endpoint> with real endpoint, for example localhost:5130):

Invoke-WebRequest -Uri "http://<endpoint>/api/notification" -Method Post

{{/enableTestToolByDefault}}
{{^enableTestToolByDefault}}
1. In the debug dropdown menu, select Dev Tunnels > Create A Tunnel (set authentication type to Public) or select an existing public dev tunnel
2. Right-click your project and select Teams Toolkit > Prepare Teams App Dependencies
3. If prompted, sign in with a Microsoft 365 account for the Teams organization you want
Expand All @@ -13,6 +23,7 @@ the notification(replace <endpoint> with real endpoint, for example localhost:51

Invoke-WebRequest -Uri "http://<endpoint>/api/notification" -Method Post

{{/enableTestToolByDefault}}
## Learn more

New to Teams app development or Teams Toolkit? Learn more about
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"launchTestTool": true,
"launchUrl": "http://localhost:56150",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "TestTool",
"AZURE_FUNCTIONS_ENVIRONMENT": "TestTool",
"TEAMSFX_NOTIFICATION_STORE_FILENAME": ".notification.testtoolstore.json",
"TEAMSFX_NOTIFICATION_LOCALSTORE_DIR": "../../.." // Path to project folder $(MSBuildProjectDirectory)
}
},
Expand All @@ -23,7 +24,7 @@
"launchBrowser": true,
"launchUrl": "https://teams.microsoft.com/l/app/${{TEAMS_APP_ID}}?installAppPackage=true&webjoin=true&appTenantId=${{TEAMS_APP_TENANT_ID}}&login_hint=${{TEAMSFX_M365_USER_NAME}}",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
"ASPNETCORE_ENVIRONMENT": "Development",
"TEAMSFX_NOTIFICATION_LOCALSTORE_DIR": "../../.." // Path to project folder $(MSBuildProjectDirectory)
}
},
Expand All @@ -37,7 +38,8 @@
"launchTestTool": true,
"launchUrl": "http://localhost:56150",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "TestTool",
"AZURE_FUNCTIONS_ENVIRONMENT": "TestTool",
"TEAMSFX_NOTIFICATION_STORE_FILENAME": ".notification.testtoolstore.json",
"TEAMSFX_NOTIFICATION_LOCALSTORE_DIR": "../../.." // Path to project folder $(MSBuildProjectDirectory)
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"BOT_ID": "",
"BOT_PASSWORD": "",
"TEAMSFX_NOTIFICATION_STORE_FILENAME": ".notification.testtoolstore.json"
"BOT_PASSWORD": ""
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

<ItemGroup>
<None Include=".notification.local*.json" />
<None Include=".notification.testtool*.json" />
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -56,6 +57,11 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
<None Update="appsettings.TestTool.json">
<DependentUpon>appsettings.json</DependentUpon>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

## Quick Start

{{#enableTestToolByDefault}}
1. Press F5, or select the Debug > Start Debugging menu in Visual Studio
2. Teams App Test Tool will be opened in the launched browser
3. [If you selected http trigger] Open Windows PowerShell and post a HTTP request to trigger
the notification(replace <endpoint> with real endpoint, for example localhost:5130):

Invoke-WebRequest -Uri "http://<endpoint>/api/notification" -Method Post

{{/enableTestToolByDefault}}
{{^enableTestToolByDefault}}
1. In the debug dropdown menu, select Dev Tunnels > Create A Tunnel (set authentication type to Public) or select an existing public dev tunnel
2. Right-click your project and select Teams Toolkit > Prepare Teams App Dependencies
3. If prompted, sign in with a Microsoft 365 account for the Teams organization you want
Expand All @@ -13,6 +23,7 @@ the notification(replace <endpoint> with real endpoint, for example localhost:51

Invoke-WebRequest -Uri "http://<endpoint>/api/notification" -Method Post

{{/enableTestToolByDefault}}
## Learn more

New to Teams app development or Teams Toolkit? Learn more about
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"launchTestTool": true,
"launchUrl": "http://localhost:56150",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "TestTool",
"AZURE_FUNCTIONS_ENVIRONMENT": "TestTool",
"TEAMSFX_NOTIFICATION_STORE_FILENAME": ".notification.testtoolstore.json",
"TEAMSFX_NOTIFICATION_LOCALSTORE_DIR": "../../.." // Path to project folder $(MSBuildProjectDirectory)
}
},
Expand All @@ -23,7 +24,7 @@
"launchBrowser": true,
"launchUrl": "https://teams.microsoft.com/l/app/${{TEAMS_APP_ID}}?installAppPackage=true&webjoin=true&appTenantId=${{TEAMS_APP_TENANT_ID}}&login_hint=${{TEAMSFX_M365_USER_NAME}}",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
"ASPNETCORE_ENVIRONMENT": "Development",
"TEAMSFX_NOTIFICATION_LOCALSTORE_DIR": "../../.." // Path to project folder $(MSBuildProjectDirectory)
}
},
Expand All @@ -37,7 +38,8 @@
"launchTestTool": true,
"launchUrl": "http://localhost:56150",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "TestTool",
"AZURE_FUNCTIONS_ENVIRONMENT": "TestTool",
"TEAMSFX_NOTIFICATION_STORE_FILENAME": ".notification.testtoolstore.json",
"TEAMSFX_NOTIFICATION_LOCALSTORE_DIR": "../../.." // Path to project folder $(MSBuildProjectDirectory)
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"BOT_ID": "",
"BOT_PASSWORD": "",
"TEAMSFX_NOTIFICATION_STORE_FILENAME": ".notification.testtoolstore.json"
"BOT_PASSWORD": ""
}
Loading

0 comments on commit 8183980

Please sign in to comment.