asackmann / msteams-tldr

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TL;DR MS Teams Bot

@mention the tldr (“Too Long; Didn't Read”) bot in a post or comment in MS Teams with a message containing a URL and to get a threaded reply with a 8 sentence summary of the web page.

tldr is a MS Teams outgoing webhook bot that runs as a Cloudflare Worker and calls an Algorithmia-hosted algorithm that performs the summarization.

Built from the MS Teams Outgoing Webhook Bot Workers Template.

The idea for this bot was inspired by a blog post from the Concur Labs team.

Implementation Details

When a configured outgoing webhook bot is @mentioned in MS Teams a POST request is sent to the worker. The worker verifies the webhook message signature using an HMAC token provided by MS Teams when creating the outgoing webhook.

The worker extracts the first URL found in the message text and sends that URL to the SummarizeURL algorithm hosted on Algorithmia.

The worker replies with a JSON response that gets rendered as a threaded reply to the conversation in MS Teams:

{
  "type": "message",
  "text": "The contents of a summary reply!"
}

Initial Setup

For the basics of getting started with Cloudflare Workers and Wrangler, refer to the getting started guide.

  1. Deployment is automated through the Wrangler GitHub Action.

  2. Create an outgoing webhook in MS Teams (docs), providing the URL for your worker.

  3. Add a worker secret variable named SECRET equal to the HMAC security token provided by MS Teams when creating the ougoing webhook. This can be configured using Wrangler:

    wrangler secret put SECRET
  4. Sign up for a free account at Algorithmia and obtain an API key.

  5. Add a worker secret variable named ALGO_KEY equal to the Algorithmia API Key.

    wrangler secret put ALGO_KEY
  6. The default number of setences in the summary is 8. You can customize this by changing the summaryLength variable.

tldr

🎉

About


Languages

Language:JavaScript 100.0%