Skip to content

A Microsoft Teams bot to create a quiz inside any chat about any subject using randomly generated questions.

License

Notifications You must be signed in to change notification settings

marcel-paalvast/msteams-quiz-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hack Together: Microsoft Graph and .NET

MsTeams Quiz Bot

A Microsoft Teams bot to create a quiz inside any chat about any subject using randomly generated questions.

Key Features

When mentioned with @bot-name quiz the bot will create an adaptive card allowing a user to setup a quiz about their specified topic and in their language. The user starting the quiz then has full control to participate and decide when to lock a question and generate the next question or to stop the quiz and show the top 10 results.

A Function App handles the messages that are received by the bot reacting to the prompts and generating responses using Microsoft's Adapative Cards. The Function App uses a Cosmos Database to maintain its state allowing it to scale and not require it to be always on (so serverless is an option). A memory cache is maintained to quickly access objects should the Function App still be active from previous requests. Questions are generated using OpenAi's ChatGpt allowing you to create an 'infinite' amount of questions on any topic without effort.

msteams-quiz-bot-demo.mp4

How to setup your own environment:

Required Resources

  1. Function App
    • Runs the api
    • Can run serverless
  2. Cosmos Database
    • Maintains the state
    • Can run serverless
    • Set up a ttl on container level to remove old data
  3. OpenAi ChatGpt
    • Generates questions based on user topic and language
  4. Bot registration
    • Bot needs to be registered on the bot framework

Example of a local.appsettings.json required to run.

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "MicrosoftAppType": "MultiTenant",
    "MicrosoftAppId": "<bot app id>",
    "MicrosoftAppPassword": "<bot password>",
    "Cosmos:Endpoint": "<endpoint uri>",
    "Cosmos:Key": "<access key>",
    "Cosmos:Database": "<database name>",
    "Cosmos:Container": "<container name>",
    "OpenAi:ApiKey": "<api key obtained from https://platform.openai.com/account/api-keys>"
  }
}

About

A Microsoft Teams bot to create a quiz inside any chat about any subject using randomly generated questions.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages