I have create Microsoft Teams App (Basic AI Chat Bot) project in Visual Studio 2022.
I am using Azure OpenAI.
I am getting below error when I ask question through my chat bot :
Error : The bot encountered an unhandled error: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index'). To continue to run this bot, please fix the bot source code.

I have given correct Azure OpenAI Key, Endpoint and Deployment model name, as I have tested another app with these keys.
Can some one guide how resolve this error ? or where can I locate Bot Source Code?
Below is my config:
appsettings.TestTool.json
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"BOT_ID": "",
"BOT_PASSWORD": "",
"Azure": {
"OpenAIApiKey": "5d**************************************GecIK",
"OpenAIEndpoint": "https://aksha-m88bx4tg-eastus2.openai.azure.com/",
"OpenAIDeploymentName": "GPT4Model"
}
}
appsettings.Development.json
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Information",
"Microsoft.Hosting.Lifetime": "Information",
"Microsoft.Teams.AI": "Trace"
}
},
"AllowedHosts": "*",
"BOT_ID": "a2*************************************0d0",
"BOT_PASSWORD": "mZ*************************************p7rb6b",
"BOT_TYPE": "MultiTenant",
"Azure": {
"OpenAIApiKey": "5dMcH*************************************OGecIK",
"OpenAIEndpoint": "https://aksha-m88bx4tg-eastus2.openai.azure.com/",
"OpenAIDeploymentName": "GPT4Model"
}
}
Development.json has Bot Id and Bot Password.
I tried giving same in TestTool.json . As well as keeping it blank in TestTool.json.
But still I am getting same error as mentioned above.
I have watched many video tutorials. Created this POC 2-3 times. I have not missed any step. But still getting issue.
Below are steps I followed:
- Create new project in visual studio with 'Microsoft Teams App' Template
- Selected 'Basic AI Chat Bot' category with .Net 8 framework
- A window will open to provide Azure OpenAI Key,endpoint , deployment Model name
- Then once project is created, in the debug dropdown menu (down arrow near Start), select Dev Tunnels > Create A Tunnel (Temporary tunnel, set authentication type to Public)
- After that right click on TeamsApp -> Teams Toolkit -> Prepare Teams App Dependencies
- After successful completion of step 5 , Run application.
- Teams App Test Tool will open. Type some input and hit enter. Getting error message instead of response.