Skip to content

Latest commit

 

History

History

msgext-ai-doc-compliance-checker

page_type description products languages extensions urlFragment
sample
This sample demonstrates how to integrate Open AI into a Teams message extension to evaluate contract proposals against policy checklists.
office-teams
copilot-m365
azure open-ai
javascript
contentType createdDate
samples
07/15/2024 01:38:25 PM
officedev-microsoft-teams-samples-msgext-ai-doc-compliance-checker-js

Compliance Checker using Azure Open AI

Explore this sample application that integrates Azure Open AI into a Teams message extension, enabling users to evaluate contract proposals for compliance with specific policy guidelines stored in Azure Blob Storage.

The solution not only presents results as interactive adaptive cards but is also compatible with Microsoft 365 Copilot, offering seamless compliance checks in your workflow.

Interaction with app

msgext-doc-compliance-checkerGif

Try It Yourself - Experience the app in your Microsoft Teams and Copilot client

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. (Sideloading must be enabled for your tenant, see steps here).

Compliance Checker sample app: Manifest

Prerequisites

Create an Azure Open AI service

  • In Azure portal, create an Azure Open AI service.
  • Deploy Azure Open AI model: Deploy the gpt-35-turbo model in your created Azure Open AI service for the application to perform translation.
  • Collect AzureOpenAIEndpoint, AzureOpenAIApiKey, AzureOpenAIDeploymentId values and save these values to update in .env file later.

Setup and use the sample

  1. Create Azure Blob Storage: Refer to the Create Blob Storage documentation Blob Storage to create a blob storage in Azure.

  2. Add the files to be checked for compliance: Upload the policy guideline document (keep the file-name handy for adding into the .localConfigs file) and also the proposal documents to compare against the guideline.

  3. Clone the repository

    git clone https://github.com/OfficeDev/Microsoft-Teams-Samples.git
  4. Navigate to the samples/msgext-ai-doc-compliance-checker folder and open with Visual Studio Code.

  5. Navigate to the samples/msgext-ai-doc-compliance-checker/.localConfigs directory and update the values below.

    When running the sample using the toolkit, the BOT_ID and BOT_PASSWORD are automatically generated for you. You do not need to manually configure these credentials

      BOT_ID={{Azure_Bot_Id}} 
      BOT_PASSWORD={{Azure_Bot_Password}}
      END_POINT={{AzureOpenAIEndpoint}}
      API_KEY={{AzureOpenAIApiKey}}
      DEPLOYMENT_ID={{AzureOpenAIDeploymentId}}
      AZURE_STORAGE_CONNECTION_STRING={{Azure_Storage_Connection_String}}
      AZURE_CONTAINER_NAME={{Azure_Container_Name}}
      CHECKLIST_NAME={{The name of the Policy Guideline document uploaded in Azure Blob should include the file extension. Supported file formats are: .pdf , .docx, .txt}}

Run the app (Using Teams Toolkit for Visual Studio Code)

The simplest way to run this sample in Teams is to use Teams Toolkit for Visual Studio Code.

  1. Ensure you have downloaded and installed Visual Studio Code
  2. Install the Teams Toolkit extension
  3. Select File > Open Folder in VS Code and choose this samples directory from the repo
  4. Using the extension, sign in with your Microsoft 365 account where you have permissions to upload custom apps
  5. Select Debug > Start Debugging or F5 to run the app in a Teams web client.
  6. 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 (sideloading), Teams 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.

Running the sample

  1. Add Compliance Checker App: ComplianceCheckerInstallApp

  2. Search for the Compliance Checker app from the Messaging Extensions: ComplianceCheckerSearchApp

  3. Select and add the Compliance Checker App: ComplianceCheckerSelectApp

  4. Search for the file name of the proposal document to compare against the policy document: ComplianceCheckerSearchFileName

  5. Compliance Assessment Result. The proposal document is checked against the guideline document and the results are shown in an adaptive card: ComplianceCheckerSelectResults

  6. Compliance Checker Results: 6.ComplianceCheckerResults

  7. Click on the arrow to expand the card and get contextual reasoning for the complaince status being Yes or No: 7.ComplianceCheckerYesResults

8.ComplianceCheckerNoResults

Test the app in Copilot for Microsoft 365

  1. Open Microsoft Teams, navigate to the Copilot section from the left-hand menu, look for the "Plug-ins" section on the right side of the screen, and use the search bar within the Plug-ins menu to search for "Compliance Checker": 10.Copilot

  2. Enable Compliance Checker app: 11.CopilotEnable

  3. Using Compliance Checker, evaluate Acme Suppliers Proposal for compliance 12.CopilotPrompt

  4. Compliance checker results are being generating: 13.CopilotResultsLoading

  5. The Compliance Checker has evaluated the Acme Suppliers Proposal and here are the results: 14.CopilotResults

  6. Click on the arrow to expand the card and get contextual reasoning for the complaince status being Yes or No: 15.CopilotCardResults

Deploy/Host your app on Azure

If you want to deploy the app to Azure, you can follow the below steps:

Further reading

Azure Open AI Service, Message Extensions And Azure Blob Storage.