Skip to content

This is the template for Yunny's Alfred Sample Bot This is Yunny's sample bot based off of EchoBot template to simulate Alfred's behaviors.

Notifications You must be signed in to change notification settings

rheehot/YunnyAlfredBotTemplate

 
 

Repository files navigation

YunnyAlfredBot

YunnyAlfredBot is a prototype of a Microsoft Teams bot, Alfred, that streamlines dev ops scenarios from multiple sources such as github, stackoverflow and emails. Image of YunnyAlfredBot

Note: You see 'BigYunsEchoBot' as a bot name in the screen shot as I registered the bot to MIcrosoft Teams by using this name. Initially, I simply named it this way as BigYuns is my nickname and I was suing the EchoBot template to create this bot. Unfortunately, I cannot change the bot name once I name it. Don't get confused the bot name with the Teams app name. The app name is 'YunnyAlfredBot', and this is the name you use to @ mention the bot. Mention YunnyAlfredBot

Try YunnyAlfredBot Locally

Prerequsites

  • You need to have an Azure subscription to use Azure CosmosDB.
  • You need to be on a plan that supports premium connectors in Microsoft Power Auotmate. If you have a work or school account, and your orgnaization supports Microsoft Power Automate, you will be able to preimum connectors, such as HTTP.

Set up the bot

  1. Register the bot with the Bot Framework via App Studio in Microsoft Teams.
  • Install App Studio app in Microsoft Teams.
  • Click 'Create an app' and fill out App details first.
  • Go to Bots under Capabilities.
    • Click 'Set up' and fill out the page.
    • Copy the Bot ID and a newly generated app passowrd. We need these values later.
    • For YunnyAlfredBot, you don't need to select anything under Messaging bot and Calling bot. The scope is only for Team.
    • More details about using App Studio are available here.
  • Don't install the bot yet.
  1. Set up a tunneling software.
  • You can use ngork or TunnelRelay.
    • If you have an azure account, I highly recommend using TunnelRelay to set up tunneling.
    • You can find how to use TunnelRelay in its github.
    • How to use ngork for Teams Bot Development: check here
  • Copy the externally addressable URL from your tunneling app. We need it later.
  1. Configure YunnyAlfredBot.sln
  • Open YunnyAlfredBot.sln file in Visual Studio.
  • Open appsettings.josn file and update it as follows:
    • Replace ADD_YOUR_BOT_APP_ID with the Application ID you received while registering your bot.
    • Replace ADD_YOUR_BOT_APP_PASSWORD with the App Password that you copied.
    • Replace ADD_YOUR_BOT_HOSTING_URL with the externally addressable URL that you copied from ngork or TunnelRelay.

Set up the Azure Cosmos DB

  • Go to Azure Portal and register a new Azure Cosmos DB database.
  • Choose "Core (SQL)" for API.
  • Create a database with name YunnyAlfredBotConfig (You can name the database whatever you want.)
  • Create the following containers:
    • ChannelConversationReference with partition-key as channelId.
    • ExternalTicketMessageId with partition-key as externalTicketId.
  • Copy the Cosmos DB endpoint URL and paste it into appsettings.json to replace ADD_COSMOS_DB_ENDPOINT_URL_HERE.
  • Copy the Cosmos DB primary key value and paste it into appsettings.json to replace ADD_COSMOS_DB_PRIMARY_KEY_HERE.
  • Copy the Cosmos DB database name and paste it into appsettings.json to replace ADD_COSMOS_DB_DATABASE_NAME.

Run YunnyAlfredBot

  • Build and deploy YunnyAlfredBot.
  • Go back to App Studio and click 'Test and distribute' under Finish.
  • Install the bot in a channel that you would like to install.
  • Once YunnyAlfreBot is installed, do '@YunnyAlfredBot connect'.
    • This will return a url to the channel. Copy this value as we need it later. YunnyAlfredBot connect

Get your Github Personal Access Token

You will need a GitHub personal access token to get all data we need from github.

  • Log in to your Github account.
  • Go to settings -> Developer Settings -> Personal Access Token.
  • Generate a new token. Github Access Token
  • Save this new token as we need this value in the next section.

Configure Micorsoft Power Automate

YunnyAlfredBot exposes an end point(flow/messages/{encryptedChannelID}). You need to configure the follwoing two flos so that each of them can send http post request to YunnyAlfredBot's designated end point when an issue is assigned to a person or when an assigned issue is closed.

  • Go to Microsoft Power Automate.
  • Change your settings to DSRE Exception - Github Connector.
    • You will need a special persmission to get this environment settings.
    • Go to Power Automate Admin Center -> Data Policies and see the owners of those policies. Contact them and ask for the permission to this settings in Microsoft Power Automate.
  • Download "[YunnyAlfredBot]Github-AssignToUser" to your local machine.
  • Once you change the setting, go to 'My Flows'.
  • Click 'import' on the top.
  • Upload "[YunnyAlfredBot]Github-AssignToUser" zip file.
    • After the zip file is uploaded, you will a page like this: After uploaded
  • Click a tool icon under 'ACTION' in the same row with 'YunnyAlfredBot GitHub-AssignToAUser Template'.
    • Change 'Update' under 'Setup' to 'Create as new'.
    • Create as new
  • Click a tool icon under 'ACTION' in the same row with 'unicorn-devwriter'.
  • Select your github account. If your github account does not exist in the list, click 'create new'. Change a user account
  • Name your flow as 'YunnyAlfredBot GitHub-AssignToAUser From Template'.
  • If you see a grey X for each row, you are all good to go for "[YunnyAlfredBot]Github-AssignToUser" flow. Import Set Up is done

Repeat the above process for "[YunnyAlfredBot]GitHub-CloseIssues flow".

Set up your Flows.

  • Open 'YunnyAlfredBot GitHub-AssignToAUser From Template' flow.
    • You will see something like this:
    • Flow
  • Go to 'Secrets' box -> Click '...' -> Click 'Settings' -> Add your github personal access token as a value of 'githubAuth' -> Click Done.
  • Click 'Switch' -> Click 'Case' -> Click 'HTTP 2'.
  • In URI section, copy the url that you got by running '@YunnyAlfredBot connect' in Teams client.
  • In body, see 'mentioned' and add the UPNs of people that you would like YunnyAlfredBot to mention.
    • Note: Only people in the channel where YunnyAlfredBot is installed can be tagged.
    • You can check a person's UPN by mentioning the personl in the channel.
    • The end result should look like this: end result

Repeat the above process for "[YunnyAlfredBot]GitHub-CloseIssues From Template" flow.

Now you are all good! For the testing purpose, you can file an issue in github and assign it to a person whose account was used to set up the two flows. This action will trigger the flow and will talk to YunnyAlfredBot.

If YunnyAlfredBot works properly, you will see the following behaviors.

  • For a new issue: Image of YunnyAlfredBot

  • When a comment is made: Image of YunnyAlfredBot

  • When the issue is closed: Image of YunnyAlfredBot

Deploy the bot to Azure

  • If you would like to deploy your bot service to azure, see Deploy your bot to Azure for a complete list of deployment instructions.

References related to Bot Framework, Bot Service and Azure

About

This is the template for Yunny's Alfred Sample Bot This is Yunny's sample bot based off of EchoBot template to simulate Alfred's behaviors.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 67.8%
  • HTML 32.2%