This sample app is designed to make it easy to integrate the powerful capabilities of OpenAI into your Microsoft Teams workflow. With just a simple POST request, you can send a message to OpenAI, receive a response, and have it formatted as a JSON object that can be easily sent to Microsoft Teams.
This is a Flask application that makes use of Azure OpenAI API to generate text based on a given prompt. This app can then be implemented in Teams as a second step to have an OpenAI Bot experience. Azure Web App will be used to host my app and expose it to the public internet. Other ways to make your app integrate with Teams exist, e.g. exposing localhost via tunnelling service such as ngrok.
- Deploy an OpenAI Model e.g. text-davinci-003 tutorial
- Create a Flask app that is able to call the OpenAI model locally with the /gpt3 endpoint code
- Create temporary outgoing webhook in Teams to get the authentication token and store it in Key Vault teamstoken tutorial
- Finalize the app code
- Host the app on publicly accessible URL by making some changes deployment center or detailed tutorial
- Replace the endpoint URL with your Web App in the outgoing Webhook
- Flask
- OpenAI
- BeautifulSoup
- Azure KeyVault
- Azure Identity
The API key for the OpenAI LLM model is stored in Azure Key Vault, and the SecretClient is used to access the API key. In a second stage, Azure Key Vault also holds the security token that you receive when creating an outgoing Webhook in Teams. This is used to authenticate calls between Teams and the designated outside service.
This app uses the OpenAI API to generate text based on the prompt. The deployment ID teams-davinci003 is used to specify which OpenAI deployment to use.