GitHunt
BO

boliu6283/TeamsGameBot

Game Bot on Teams

GameBot

Epic

Gamify working environment with a online Teams board game lobby to tighten up colleagues bonds in unprecedented time.

https://jolly-game.com/

Stack

Architecture

Main Flow Overview
index.js (server hosting)
=> adapter (convert HTTP request into turnContext)
=> bots (application module activity handlers)
=> dialogs (dialogs stack handling using dialogs)
=> steps (steps in waterfall state machine)
=> resolvers (database access layer)

Folder Structure:

  • .env: process environment variable will be propagated into process.env. dictionary
  • index.js: entrypoint of the application
  • bots: bot modules need to be loaded
  • config: constants will be used inside the application
  • dialogs: conversation handlers
  • helpers: miscellaneous functions
  • models: database model mapping, like the M in ASP.NET MVC framework
  • resolvers: database access layer, operations on data
  • static: static resources, like json and images
  • tests: unittesting scenarios

Prerequisites

Essential

Optional

Setup Development Environment

  1. Ensure nodejs>=12. is installed
    1. Open a shell (cmd/powershell), node --version should return v12.x.x
    2. npm --version should return 6.x.x
  2. Ensure ngrok is installed
    1. .\ngrok.exe --version should return ngrok version 2.x.x
  3. Git Clone this repository
  4. Resolve the NodeJs package.json dependencies using npm install
    1. Run npm install
  5. Create a personal Microsoft Teams application for development
    1. Go to Microsoft Teams => Left Panel => ... => Search "App Studio"
      1. Setup Teams App
    2. Fill in the information for your new bot
      1. In Bots section, DO NOT CHECK "one-way communication"
      2. Setup Bots App
  6. Setup environment ./.env correctly
    1. MicrosoftAppId = App Studio => Bots => UUID above "App passwords"
    2. MicrosoftAppPassword = App Studio => Bots => App passwords
    3. db = Mongo db connection string (acquire from teammates' setting)
    4. DebugMode = **emulator** for local bot-emulator debug, **teams** for remote debug
    5. VSCode Environment

Everyday Development

  1. Sync the repository by git pull or git fetch; git rebase.
  2. Start the bot server with npm run start or VSCode F5
  3. After the server starts up, use ngrok.exe http 3978 -host-header=localhost:3978 to expose your local port into public. DO NOT TURN OFF ngrok.exe when restarting NodeJs server. Otherwise, you need to replay step 4.
  4. Change bot message endpoint
  5. VSCode Daily Development

LUIS application to enable language understanding

The LUIS model for this example can be found under cognitiveModels/FlightBooking.json and the LUIS language model setup, training, and application configuration steps can be found here.

Once you created the LUIS model, update .env with your LuisAppId, LuisAPIKey and LuisAPIHostName.

LuisAppId="Your LUIS App Id"
LuisAPIKey="Your LUIS Subscription key here"
LuisAPIHostName="Your LUIS App region here (i.e: westus.api.cognitive.microsoft.com)"

Testing the bot using Bot Framework Emulator

Bot Framework Emulator is a desktop application that allows bot developers to test and debug their bots on localhost or running remotely through a tunnel.

  • Install the Bot Framework Emulator version 4.3.0 or greater from here

Connect to the bot using Bot Framework Emulator

  • Launch Bot Framework Emulator
  • File -> Open Bot
  • Enter a Bot URL of http://localhost:3978/api/messages

Deploy the bot to Azure

To learn more about deploying a bot to Azure, see Deploy your bot to Azure for a complete list of deployment instructions.

Further reading

boliu6283/TeamsGameBot | GitHunt