Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1929 from howdyai/benbrown/4.7
Browse files Browse the repository at this point in the history
Next Release
  • Loading branch information
benbrown authored Mar 17, 2020
2 parents 74684be + 56f2fcd commit 7bcb100
Show file tree
Hide file tree
Showing 35 changed files with 2,326 additions and 1,550 deletions.
27 changes: 27 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,33 @@

[Want to contribute? Read our guide!](https://github.com/howdyai/botkit/blob/master/CONTRIBUTING.md)

# 4.8

In addition to fixing a bunch of bugs and adding some new features, this version brings Botkit up to date with Bot Framework's latest release - [Change log here](https://github.com/microsoft/botbuilder-js/releases).

There are lots of interesting things happening in the Bot Framework world including a new [GUI for dialog management called Bot Framework Composer](https://github.com/microsoft/botframework-composer), a new templating system called [Language Generation](https://github.com/microsoft/BotBuilder-Samples/tree/master/experimental/language-generation), and more. Check out the [main hub repo for more information.](https://github.com/microsoft/botframework-sdk#readme)

### NEW

* NEW: At long last, the convo.ask callbacks can receive the full incoming message payload in addition to the text content.
This allows developers to use payload values inside quick replies, button clicks and other rich operations. Many thanks to [@naikus](https://github.com/naikus) for the effort and patience it took to get this in! [PR #1801](https://github.com/howdyai/botkit/pull/1801)
* NEW: Multi-adapter support improved. Botkit will now spawn the appropriate type of Botworker when used in a multi-adapter scenario. [See this example for a demonstration of using multiple adapters in a single bot app](./packages/testbot/multiadapter.js). [Issue #1920](https://github.com/howdyai/botkit/issues/1920)
* NEW: Add support for Slack's v2 oauth. [More details here](./packages/botbuilder-adapter-slack/CHANGELOG.md#109). Thanks to [@sfny](https://github.com/sfny) for [PR #1928](https://github.com/howdyai/botkit/pull/1928)
* NEW: Values in `channelData` will now be processed as Mustache templates inside BotkitConversations. [Thanks @me-cedric](https://github.com/me-cedric) for [pr #1925](https://github.com/howdyai/botkit/pull/1925)
* NEW: New Dialog related features for determining if a bot is already in a conversation, including [bot.hasActiveDialog()](packages/docs/reference/core.md#hasActiveDialog),
[bot.getActiveDialog()](packages/docs/reference/core.md#getActiveDialog), and
[bot.isDialogActive()](packages/docs/reference/core.md#isDialogActive)

### FIXED

* FIX: Facebook Adapter will not attempt to set up web routes if webserver is not configured. [#1916](https://github.com/howdyai/botkit/issues/1916)
* FIX: Exclude `activity.conversation.properties` field when generating state storage key. [#1849](https://github.com/howdyai/botkit/issues/1849)
* FIX: Allow startConversationWithUser to work with Bot Framework Emulator. [#1834](https://github.com/howdyai/botkit/issues/1834)
* FIX: Using `beginDialog` inside an `ask()` caused weird behaviors. Fixes for [#1878](https://github.com/howdyai/botkit/issues/1878) and [#1932](https://github.com/howdyai/botkit/issues/1932)
* FIX: Webex - remove empty `files` key [#1906](https://github.com/howdyai/botkit/pull/1906)
* FIX: Slack - authed_users added to message [#1911](https://github.com/howdyai/botkit/issues/1911)
* Update: all dependencies to latest, including bot framework 4.7->4.8 and mustache 3.0 -> 4.0

# 4.6.1

Version 4.6.1 includes some security and bugfix updates along with bumping many dependencies to the latest versions.
Expand Down
6 changes: 3 additions & 3 deletions packages/botbuilder-adapter-facebook/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "botbuilder-adapter-facebook",
"version": "1.0.8",
"version": "1.0.9",
"description": "Connect Botkit or BotBuilder to Facebook Messenger",
"main": "lib/index.js",
"typings": "./lib/index.d.ts",
Expand Down Expand Up @@ -34,8 +34,8 @@
"url": "https://github.com/howdyai/botkit.git"
},
"dependencies": {
"botbuilder": "^4.7.1",
"botkit": "^4.6.2",
"botbuilder": "^4.8.0",
"botkit": "^4.8.0",
"debug": "^4.1.0"
},
"devDependencies": {
Expand Down
20 changes: 11 additions & 9 deletions packages/botbuilder-adapter-facebook/src/facebook_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export class FacebookAdapter extends BotAdapter {

this.middlewares = {
spawn: [
async (bot, next) => {
async (bot, next): Promise<void> => {
bot.api = await this.getAPI(bot.getConfig('activity'));
next();
}
Expand All @@ -148,15 +148,17 @@ export class FacebookAdapter extends BotAdapter {
*/
public async init(botkit): Promise<any> {
debug('Add GET webhook endpoint for verification at: ', botkit.getConfig('webhook_uri'));
botkit.webserver.get(botkit.getConfig('webhook_uri'), (req, res) => {
if (req.query['hub.mode'] === 'subscribe') {
if (req.query['hub.verify_token'] === this.options.verify_token) {
res.send(req.query['hub.challenge']);
} else {
res.send('OK');
if (botkit.webserver) {
botkit.webserver.get(botkit.getConfig('webhook_uri'), (req, res) => {
if (req.query['hub.mode'] === 'subscribe') {
if (req.query['hub.verify_token'] === this.options.verify_token) {
res.send(req.query['hub.challenge']);
} else {
res.send('OK');
}
}
}
});
});
}
}

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/botbuilder-adapter-hangouts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "botbuilder-adapter-hangouts",
"version": "1.0.5",
"version": "1.0.6",
"description": "Connect Botkit or BotBuilder to Google Hangouts",
"main": "./lib/index.js",
"typings": "./lib/index.d.ts",
Expand Down Expand Up @@ -34,9 +34,9 @@
"url": "https://github.com/howdyai/botkit.git"
},
"dependencies": {
"botbuilder": "^4.7.1",
"botbuilder": "^4.8.0",
"googleapis": "^34.0.0",
"botkit": "^4.6.2",
"botkit": "^4.8.0",
"debug": "^4.1.0"
},
"devDependencies": {
Expand Down
6 changes: 6 additions & 0 deletions packages/botbuilder-adapter-slack/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# botbuilder-adapter-slack changelog

# 1.0.9

* Update @slack/web-api to 5.8.0
* Add `oauthVersion` parameter to constructor. If set to `v2`, oauth features will use Slack's latest auth functions and urls. [More info](readme.md#using-slacks-v2-oauth)
* Make `authed_users` field available. [Fix for #1911](https://github.com/howdyai/botkit/issues/1911)

# 1.0.8

* Update @slack/web-api to 5.7.0 which includes access to new Oauth features (see [#1890](https://github.com/howdyai/botkit/pull/1890))
Expand Down
8 changes: 4 additions & 4 deletions packages/botbuilder-adapter-slack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "botbuilder-adapter-slack",
"version": "1.0.8",
"version": "1.0.9",
"description": "Connect Botkit or BotBuilder to Slack",
"main": "./lib/index.js",
"typings": "./lib/index.d.ts",
Expand Down Expand Up @@ -33,9 +33,9 @@
"url": "https://github.com/howdyai/botkit.git"
},
"dependencies": {
"@slack/web-api": "^5.7.0",
"botbuilder": "^4.7.1",
"botkit": "^4.6.2",
"@slack/web-api": "^5.8.0",
"botbuilder": "^4.8.0",
"botkit": "^4.8.0",
"debug": "^4.1.0"
},
"devDependencies": {
Expand Down
26 changes: 22 additions & 4 deletions packages/botbuilder-adapter-slack/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ const adapter = new SlackAdapter({
clientSigningSecret: process.env.SLACK_SECRET,
clientId: process.env.CLIENTID, // oauth client id
clientSecret: process.env.CLIENTSECRET, // oauth client secret
scopes: ['bot'], // oauth scopes requested
scopes: ['bot'], // oauth scopes requested, 'bot' deprecated by Slack in favor of granular permissions
redirectUri: process.env.REDIRECT_URI, // url to redirect post-login
oauthVersion: 'v1', // or use v2
getTokenForTeam: async(team_id) => {
// load the token for this team
// as captured during oauth
Expand All @@ -123,9 +124,9 @@ controller.webserver.get('/install/auth', (req, res) => {
const results = await controller.adapter.validateOauthCode(req.query.code);

// Store token by team in bot state.
let team = results.team_id;
let token = results.bot.bot_access_token;
let userId = results.bot.bot_user_id;
let team = results.team_id; // results.team.id in oauth v2
let token = results.bot.bot_access_token; // results.access_token in oauth v2
let userId = results.bot.bot_user_id; // results.bot_user_id in oauth v2

// Securely store the token and usedId so that they can be retrieved later by the team id.
// ...
Expand All @@ -142,6 +143,23 @@ controller.webserver.get('/install/auth', (req, res) => {
});
```

### Using Slack's v2 OAuth

To use Slack's [newer "granular scopes"](https://api.slack.com/authentication/oauth-v2), specify `oauthVersion: 'v2'` in your adapter configuration.
This will cause the adapter to use the v2 oauth URL and credential validation function.
However, note that the payload returned `validateOauthCode` differs between versions.

In v1, your bot's token will be located at `results.bot.bot_access_token`, whereas in v2, it will be `results.access_token`.

In v1, your bot's user id will be at `results.bot.bot_user_id`, whereas in v2 it will be `results.bot_user_id`.

From Slack's official docs:

* [V1 response payload](https://api.slack.com/methods/oauth.access#response)
* [V2 response payload](https://api.slack.com/methods/oauth.v2.access#response)

Take care to update your auth handler function when you migrate to granular scopes.

## Class Reference

* [SlackAdapter](../docs/reference/slack.md#slackadapter)
Expand Down
6 changes: 3 additions & 3 deletions packages/botbuilder-adapter-slack/src/botworker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export class SlackBotWorker extends BotWorker {
msg.conversation.thread_ts = src.incoming_message.channelData.thread_ts;
}

msg = this.controller.adapter.activityToSlack(msg);
msg = this.getConfig('context').adapter.activityToSlack(msg);

const requestOptions = {
uri: src.incoming_message.channelData.response_url,
Expand Down Expand Up @@ -336,7 +336,7 @@ export class SlackBotWorker extends BotWorker {
* @param update An object in the form `{id: <id of message to update>, conversation: { id: <channel> }, text: <new text>, card: <array of card objects>}`
*/
public async updateMessage(update: Partial<BotkitMessage>): Promise<any> {
return this.controller.adapter.updateActivity(
return this.getConfig('context').adapter.updateActivity(
this.getConfig('context'),
update
);
Expand All @@ -356,7 +356,7 @@ export class SlackBotWorker extends BotWorker {
* @param update An object in the form of `{id: <id of message to delete>, conversation: { id: <channel of message> }}`
*/
public async deleteMessage(update: Partial<BotkitMessage>): Promise<any> {
return this.controller.adapter.deleteActivity(
return this.getConfig('context').adapter.deleteActivity(
this.getConfig('context'),
{
activityId: update.id,
Expand Down
41 changes: 32 additions & 9 deletions packages/botbuilder-adapter-slack/src/slack_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export class SlackAdapter extends BotAdapter {
* clientId: process.env.CLIENT_ID, // oauth client id
* clientSecret: process.env.CLIENT_SECRET, // oauth client secret
* scopes: ['bot'], // oauth scopes requested
* oauthVersion: 'v1',
* redirectUri: process.env.REDIRECT_URI, // url to redirect post login defaults to `https://<mydomain>/install/auth`
* getTokenForTeam: async(team_id) => Promise<string>, // function that returns a token based on team id
* getBotUserByTeam: async(team_id) => Promise<string>, // function that returns a bot's user id based on team id
Expand Down Expand Up @@ -151,6 +152,11 @@ export class SlackAdapter extends BotAdapter {
debug('** Slack adapter running in multi-team mode.');
}

if (!this.options.oauthVersion) {
this.options.oauthVersion = 'v1';
}
this.options.oauthVersion = this.options.oauthVersion.toLowerCase();

if (this.options.enable_incomplete) {
const warning = [
'',
Expand Down Expand Up @@ -242,9 +248,13 @@ export class SlackAdapter extends BotAdapter {
* @returns A url pointing to the first step in Slack's oauth flow.
*/
public getInstallLink(): string {
let redirect = '';
if (this.options.clientId && this.options.scopes) {
let redirect = 'https://slack.com/oauth/authorize?client_id=' + this.options.clientId + '&scope=' + this.options.scopes.join(',');

if (this.options.oauthVersion === 'v2') {
redirect = 'https://slack.com/oauth/v2/authorize?client_id=' + this.options.clientId + '&scope=' + this.options.scopes.join(',');
} else {
redirect = 'https://slack.com/oauth/authorize?client_id=' + this.options.clientId + '&scope=' + this.options.scopes.join(',');
}
if (this.options.redirectUri) {
redirect += '&redirect_uri=' + encodeURIComponent(this.options.redirectUri);
}
Expand All @@ -256,7 +266,7 @@ export class SlackAdapter extends BotAdapter {
}

/**
* Validates an oauth code sent by Slack during the install process.
* Validates an oauth v2 code sent by Slack during the install process.
*
* An example using Botkit's internal webserver to configure the /install/auth route:
*
Expand All @@ -265,9 +275,9 @@ export class SlackAdapter extends BotAdapter {
* try {
* const results = await controller.adapter.validateOauthCode(req.query.code);
* // make sure to capture the token and bot user id by team id...
* const team_id = results.team_id;
* const token = results.bot.bot_access_token;
* const bot_user = results.bot.bot_user_id;
* const team_id = results.team.id;
* const token = results.access_token;
* const bot_user = results.bot_user_id;
* // store these values in a way they'll be retrievable with getBotUserByTeam and getTokenForTeam
* } catch (err) {
* console.error('OAUTH ERROR:', err);
Expand All @@ -280,12 +290,18 @@ export class SlackAdapter extends BotAdapter {
*/
public async validateOauthCode(code: string): Promise<any> {
const slack = new WebClient();
const results = await slack.oauth.access({
const details = {
code: code,
client_id: this.options.clientId,
client_secret: this.options.clientSecret,
redirect_uri: this.options.redirectUri
});
};
let results: any = {};
if (this.options.oauthVersion === 'v2') {
results = await slack.oauth.v2.access(details);
} else {
results = await slack.oauth.access(details);
}
if (results.ok) {
return results;
} else {
Expand Down Expand Up @@ -606,6 +622,9 @@ export class SlackAdapter extends BotAdapter {
}
}

// Copy over the authed_users
activity.channelData.authed_users = event.authed_users;

// @ts-ignore this complains because of extra fields in conversation
activity.recipient.id = await this.getBotUserByTeam(activity as Activity);

Expand Down Expand Up @@ -723,9 +742,13 @@ export interface SlackAdapterOptions {
*/
clientSecret?: string;
/**
* A an array of scope names that are being requested during the oauth process. Must match the scopes defined at api.slack.com
* A array of scope names that are being requested during the oauth process. Must match the scopes defined at api.slack.com
*/
scopes?: string[];
/**
* Which version of Slack's oauth protocol to use, v1 or v2. Defaults to v1.
*/
oauthVersion?: string;
/**
* The URL users will be redirected to after an oauth flow. In most cases, should be `https://<mydomain.com>/install/auth`
*/
Expand Down
6 changes: 3 additions & 3 deletions packages/botbuilder-adapter-twilio-sms/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "botbuilder-adapter-twilio-sms",
"version": "1.0.4",
"version": "1.0.5",
"description": "Connect Botkit or BotBuilder to Twilio SMS",
"main": "./lib/index.js",
"typings": "./lib/index.d.ts",
Expand Down Expand Up @@ -37,8 +37,8 @@
"url": "https://github.com/howdyai/botkit.git"
},
"dependencies": {
"botbuilder": "^4.7.1",
"botkit": "^4.6.2",
"botbuilder": "^4.8.0",
"botkit": "^4.8.0",
"debug": "^4.1.0",
"twilio": "^3.29.2"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/botbuilder-adapter-web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "botbuilder-adapter-web",
"version": "1.0.6",
"version": "1.0.7",
"description": "Connect Botkit or BotBuilder to the Web",
"main": "./lib/index.js",
"typings": "./lib/index.d.ts",
Expand Down Expand Up @@ -35,8 +35,8 @@
"url": "https://github.com/howdyai/botkit.git"
},
"dependencies": {
"botkit": "^4.6.2",
"botbuilder": "^4.7.1",
"botkit": "^4.8.0",
"botbuilder": "^4.8.0",
"debug": "^4.1.0",
"url": "^0.11.0",
"ws": "^7.1.1"
Expand Down
6 changes: 6 additions & 0 deletions packages/botbuilder-adapter-webex/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# botbuilder-adapter-webex changelog

# 1.0.6

* Fix issue where empty files field would cause issues. Thanks to [@viveksyngh](https://github.com/viveksyngh) - [PR #1906](https://github.com/howdyai/botkit/pull/1906)
* Update to latest Webex API client library.


# 1.0.5

* Update to latest Webex API client library.
Expand Down
8 changes: 4 additions & 4 deletions packages/botbuilder-adapter-webex/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "botbuilder-adapter-webex",
"version": "1.0.5",
"version": "1.0.7",
"description": "Connect Botkit or BotBuilder to Webex Teams",
"main": "./lib/index.js",
"typings": "./lib/index.d.ts",
Expand Down Expand Up @@ -33,11 +33,11 @@
"url": "https://github.com/howdyai/botkit.git"
},
"dependencies": {
"botbuilder": "^4.7.1",
"botkit": "^4.6.2",
"botbuilder": "^4.8.0",
"botkit": "^4.8.0",
"debug": "^4.1.0",
"url": "^0.11.0",
"webex": "^1.80.36"
"webex": "^1.80.148"
},
"devDependencies": {
"eslint": "^6.8.0",
Expand Down
Loading

0 comments on commit 7bcb100

Please sign in to comment.