Skip to content

feat: Microsoft Teams Integration#7150

Merged
mayberryzane merged 36 commits intohighlight:mainfrom
jemiluv8:microsoft-teams-integration-bot
Jan 31, 2024
Merged

feat: Microsoft Teams Integration#7150
mayberryzane merged 36 commits intohighlight:mainfrom
jemiluv8:microsoft-teams-integration-bot

Conversation

@jemiluv8
Copy link
Copy Markdown
Contributor

@jemiluv8 jemiluv8 commented Nov 14, 2023

Summary

Microsoft teams bot integration
fixes #6858

ROADMAP

  • Support adding/removing ms teams integration - this just sets up the tenantId and gives our microsoft application access to the tenants ms teams and other related resources
  • Support sending notifications via microsoft teams channels for all alert types - session, log, error.
  • Figure out bot registration issues for tenant
  • Implement support for fetching actual channels on team the bot is installed on
  • Test support for all alert types - session, log and error. Seek design comment if any.
  • Final testing and delivery
  • Assist in publishing the bot to the msteams store

How did you test this change?

Highlight UI Integration

  • Visit integrations page
  • Observe a new integration titled, Microsoft Teams
  • Toggle the Microsoft teams integration
  • Follow the redirect to authorize app permission
  • Observe the integration is successfully "synced" with highlight
  • Observe that you are able to "remove" the microsoft teams integration

Bot Integration

  • Install the highlight notifications bot to any team under the tenant for which the integration was authoriized in the step above
  • Once installed, a message is sent to the teams channel where the app was installed
  • If no such message was sent in a reasonable amount of time, it is possible the "Highlight UI Integration" didn't work. You might have to go back to step one and start over

Local Testing

Setting Up the bot

  • Register a bot with the microsoft bot framework https://dev.botframework.com/bots
  • Under the bot's settings, set URL to point to either a local instance via (ngrok) or a hosted one
  • Send a "ping" message to test that the url was set up correctly - if the setup was done well, you'll receive a response.

Teams App Installation

To install the teams bot - before it is published - follow the instructions here

A sample manifest can be found at https://drive.google.com/file/d/1JRp6vT_2wRaDu4bMBsrOdH_M5zcY5ApP/view?usp=sharing. That is specific to my app so you'd need to unzip the file, make your bot specific modifications and then zip it.

Are there any deployment considerations?

New Environment Variables
MICROSOFT_TEAMS_BOT_PASSWORD (This is the same as the client secret generated for you microsoft application)
MICROSOFT_TEAMS_BOT_ID

Api Permissions

Ensure the Application has the following api permissions
Screenshot 2024-01-02 at 5 02 43 PM

New Workspace Fields

MicrosoftTeamsTenantId *string
MicrosoftTeamsChannels *string

Complete Demo

The link below demonstrates integration and bot setup.
We cannot initiate bot installation from the UI until the bot is "published" to the microsoft store.
https://drive.google.com/file/d/1jR_2o1LkCcjH-Q8LQgD4qIEUo6k4Re1g/view?usp=sharing

Sample Messages

Screenshot 2024-01-03 at 5 59 51 PM Screenshot 2024-01-03 at 6 00 02 PM Screenshot 2024-01-03 at 6 00 24 PM Screenshot 2024-01-03 at 6 00 45 PM

Does this work require review from our design team?

Not yet

Screenshot 2023-11-14 at 3 34 45 PM

Currently using adminconsent and evidence for integration is just a tenantId that we store on the workspace.

The above is subject to change
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Nov 14, 2023

⚠️ No Changeset found

Latest commit: b3f4d3d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

💥 An error occurred when fetching the changed packages and changesets in this PR
Some errors occurred when validating the changesets config:
The package or glob expression "@highlight-run/rrdom" is specified in the `ignore` option but it is not found in the project. You may have misspelled the package name or provided an invalid glob expression. Note that glob expressions must be defined according to https://www.npmjs.com/package/micromatch.
The package or glob expression "@highlight-run/rrdom-nodejs" is specified in the `ignore` option but it is not found in the project. You may have misspelled the package name or provided an invalid glob expression. Note that glob expressions must be defined according to https://www.npmjs.com/package/micromatch.
The package or glob expression "@highlight-run/rrweb" is specified in the `ignore` option but it is not found in the project. You may have misspelled the package name or provided an invalid glob expression. Note that glob expressions must be defined according to https://www.npmjs.com/package/micromatch.
The package or glob expression "@highlight-run/rrweb-player" is specified in the `ignore` option but it is not found in the project. You may have misspelled the package name or provided an invalid glob expression. Note that glob expressions must be defined according to https://www.npmjs.com/package/micromatch.
The package or glob expression "@highlight-run/rrweb-snapshot" is specified in the `ignore` option but it is not found in the project. You may have misspelled the package name or provided an invalid glob expression. Note that glob expressions must be defined according to https://www.npmjs.com/package/micromatch.
The package or glob expression "@highlight-run/rrweb-types" is specified in the `ignore` option but it is not found in the project. You may have misspelled the package name or provided an invalid glob expression. Note that glob expressions must be defined according to https://www.npmjs.com/package/micromatch.
The package or glob expression "@highlight-run/rrweb-web-extension" is specified in the `ignore` option but it is not found in the project. You may have misspelled the package name or provided an invalid glob expression. Note that glob expressions must be defined according to https://www.npmjs.com/package/micromatch.
The package or glob expression "rrvideo" is specified in the `ignore` option but it is not found in the project. You may have misspelled the package name or provided an invalid glob expression. Note that glob expressions must be defined according to https://www.npmjs.com/package/micromatch.

Jemilu Mohammed added 15 commits November 21, 2023 00:53
update session, alert and error alert pages to allow setting teams channel
register endpoint to receive teams events
implement teams integration with links to conversation reference and stuff
finalize relevant environment variables
…nvo will be limited.

introduce support for new session alert (TESTED) and  ErrorFeedback alert (UNTESTED)
- 4 bot messages are pending testing.
setup and sending of messages works

there are three messages pending tests
fix bugs in ms teams bot messages
Copy link
Copy Markdown
Contributor Author

@jemiluv8 jemiluv8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self Review completed

@jemiluv8 jemiluv8 marked this pull request as ready for review January 3, 2024 19:15
@Vadman97 Vadman97 requested review from a team and mayberryzane and removed request for a team January 8, 2024 16:56
@jemiluv8
Copy link
Copy Markdown
Contributor Author

I've introduced support for fetching the ms teams channels directly from the microsoft graph api.

@mayberryzane
Copy link
Copy Markdown
Contributor

thanks @jemiluv8 , testing this today

@mayberryzane
Copy link
Copy Markdown
Contributor

@jemiluv8 just made a couple more changes - I stopped saving the groups with the workspace and instead just save tenant id, then use the /teams endpoint to load all teams. Tested a concurrent / non-concurrent version on a teams instance with 6 teams, took 1.6s for the concurrent version and 3.5s for the non-concurrent one so decided to keep it concurrent (changed it to use the errgroup library). For permissions, I think it just needs these:
Screen Shot 2024-01-29 at 3 34 20 PM

Should be good to merge in now, I'll make sure it gets merged in / passes checks. Thanks for all your work here!

@mayberryzane mayberryzane self-requested a review January 29, 2024 23:35
@jemiluv8
Copy link
Copy Markdown
Contributor Author

Just to clarify

The changes look good to me.

One issue with fetching all teams(under the tenant) and then all channels is that we cannot send to a channel until the bot is installed on the team. At the moment, we don't "default install" the bot on all teams under the tenant.

This means

So we can setup an alert to be sent to a teams channel that will not receive the message if the bot is not installed on the "team"

Conclusion

That was the reason I was storing the list of teams the bot was installed on in the workspace. So I only fetch the channels for these teams. Also, when a bot is uninstalled from a team, we remove the team from the list of teams. That fixes the above issue to some extent.

Options

One thing we could do is to "auto install" the teams bot on all teams in the channel.

@mayberryzane
Copy link
Copy Markdown
Contributor

@jemiluv8 thanks for the additional context, I just added another check to verify that our app is installed in the team by using this api. Not great because it's a 2n+1 query, but in testing this took about 2s which should be fine as it's only when loading the alerts page for users with many team. We can look at optimizing in the future if this becomes a user pain point, but it keeps all the state of which teams our bot is installed on on the MS Teams side so there's no issue of keeping our state in sync. Will merge this in today

@jemiluv8
Copy link
Copy Markdown
Contributor Author

jemiluv8 commented Jan 30, 2024

Your update works just fine and fixes the issues I outlined in the clarification.
I think I finally understand our differing “points of view” about “state”

Your preference for not having some state to keep in sync helps avoid a lot of problems
with managing state even though it may not be the most performant.

At the same time too doing all this exxtra work to sync state over time can lead to bugs that we may have a hard time
keeping track of. The trade-off in this case makes sense because performance is not the priority right now. And the expected
number of users using this feature is “expected to be low”.

I’ll keep this in mind for future work on integrations. Its been cool collaborating on this.

auto-merge was automatically disabled January 30, 2024 23:26

Head branch was pushed to by a user without write access

@mayberryzane mayberryzane enabled auto-merge (squash) January 31, 2024 00:28
@mayberryzane mayberryzane merged commit af31eaa into highlight:main Jan 31, 2024
@Vadman97
Copy link
Copy Markdown
Member

/tip @jemiluv8 200

@algora-pbc
Copy link
Copy Markdown

algora-pbc bot commented Apr 27, 2024

@Vadman97
Copy link
Copy Markdown
Member

/tip $200 @jemiluv8

@algora-pbc
Copy link
Copy Markdown

algora-pbc bot commented Apr 27, 2024

🎉🎈 @jemiluv8 has been awarded $200! 🎈🎊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Microsoft Teams Integration

3 participants