This example shows how to create a basic conversational experience using OpenAI's Assistants API's. It leverages OpenAI's Code Interpreter tool to create an assistant that's an expert on math.
All the samples in the C# .NET SDK can be set up in the same way. You can find the step by step instructions here: Setup Instructions.
Note that, this sample requires AI service and Assistant so you need pre-steps before Local Debug (F5).
Create new OpenAI Assistant (You can skip this step if already have one Assistant)
-
Set your OpenAI API key to appsettings.Development.json.
"OpenAI": { "ApiKey": "<your-openai-api-key>" }
-
Run the code and it will create an OpenAI Assistant and output it's ID to console.
Use OpenAI Assistant
-
Set your OpenAI API key and Assistant ID to appsettings.Development.json.
"OpenAI": { "ApiKey": "<your-openai-api-key>", "AssistantId": "<your-openai-assistant-id>" }
-
Now you can run/debug project as Teams App.
Interacting with the bot is simple - talk to it! You can invoke it by using @ mention and talk to it in plain language.
You can use Teams Toolkit for Visual Studio or CLI to host the bot in Azure. The sample includes Bicep templates in the /infra
directory which are used by the tools to create resources in Azure.
You can find deployment instructions here.
Note that, this sample requires AI service so you need one more pre-step before deploy to Azure. To configure the Azure resources to have an environment variable for the OpenAI Key and other settings:
-
In
./env/.env.dev.user
file, paste your OpenAI related variables.SECRET_OPENAI_API_KEY= SECRET_OPENAI_ASSISTANT_ID=
The SECRET_
prefix is a convention used by Teams Toolkit to mask the value in any logging output and is optional.
Here's a list of the different capabilities shown in this sample: