marcel-paalvast / msteams-quiz-bot

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

License:MIT License


Languages

Language:C# 100.0%