Skip to content

Commit

Permalink
Enabled communication with remote Direct Line Speech bots (#2079)
Browse files Browse the repository at this point in the history
* Enabled communication with remote DL Speech bots.

* Build improvements

* Fix undefined reference error.

* Addressed PR comments.

* Fixed tests.
  • Loading branch information
tonyanziano committed Feb 20, 2020
1 parent 8ca1397 commit 49f2346
Show file tree
Hide file tree
Showing 36 changed files with 994 additions and 128 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [client/main] Added Ngrok Status Viewer in PR [2032](https://github.com/microsoft/BotFramework-Emulator/pull/2032)
- [client/main] Changed conversation infrastructure to use Web Sockets to communicate with Web Chat in PR [2034](https://github.com/microsoft/BotFramework-Emulator/pull/2034)
- [client/main] Added new telemetry events and properties in PR [2063](https://github.com/microsoft/BotFramework-Emulator/pull/2063)
- [client] Added support for talking to remote Direct Line Speech bots in PR [2079](https://github.com/microsoft/BotFramework-Emulator/pull/2079)

## Fixed
- [client] Hid services pane by default in PR [2059](https://github.com/microsoft/BotFramework-Emulator/pull/2059)
Expand Down
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 37 additions & 14 deletions packages/app/client/src/state/sagas/botSagas.spec.ts
Expand Up @@ -274,12 +274,19 @@ describe('The botSagas', () => {
ok: false,
status: 500,
statusText: 'INTERNAL SERVER ERROR',
text: async () => undefined,
};
gen.next(mockStartConvoResponse); // startConversation
try {
gen.next(mockStartConvoResponse); // startConversation
gen.next('Cannot read property "id" of undefined.');
expect(true).toBe(false); // ensure catch is hit
} catch (e) {
expect(e).toEqual(new Error('Error occurred while starting a new conversation: 500: INTERNAL SERVER ERROR'));
expect(e).toEqual({
description: '500 INTERNAL SERVER ERROR',
message: 'Error occurred while starting a new conversation',
innerMessage: 'Cannot read property "id" of undefined.',
status: 500,
});
}
});

Expand Down Expand Up @@ -323,15 +330,23 @@ describe('The botSagas', () => {
);
gen.next(); // put open()

gen.next({
ok: false,
status: 500,
statusText: 'INTERNAL SERVER ERROR',
text: async () => undefined,
}); // sendInitialLogReport()

try {
gen.next({
ok: false,
status: 500,
statusText: 'INTERNAL SERVER ERROR',
}); // sendInitialLogReport()
gen.next('Could not read property "id" of undefined.');
expect(true).toBe(false); // ensure catch is hit
} catch (e) {
expect(e).toEqual(new Error('Error occurred while sending the initial log report: 500: INTERNAL SERVER ERROR'));
expect(e).toEqual({
description: '500 INTERNAL SERVER ERROR',
message: 'Error occurred while sending the initial log report',
innerMessage: 'Could not read property "id" of undefined.',
status: 500,
});
}
});

Expand Down Expand Up @@ -377,15 +392,23 @@ describe('The botSagas', () => {

gen.next({ ok: true }); // sendInitialLogReport()

gen.next({
ok: false,
status: 500,
statusText: 'INTERNAL SERVER ERROR',
text: async () => undefined,
}); // sendInitialActivity()

try {
gen.next({
ok: false,
status: 500,
statusText: 'INTERNAL SERVER ERROR',
}); // sendInitialActivity()
gen.next('Could not read property "id" of undefined.');
expect(true).toBe(false); // ensure catch is hit
} catch (e) {
expect(e).toEqual(new Error('Error occurred while sending the initial activity: 500: INTERNAL SERVER ERROR'));
expect(e).toEqual({
description: '500 INTERNAL SERVER ERROR',
message: 'Error occurred while sending the initial activity',
innerMessage: 'Could not read property "id" of undefined.',
status: 500,
});
}
});
});
21 changes: 10 additions & 11 deletions packages/app/client/src/state/sagas/botSagas.ts
Expand Up @@ -55,6 +55,7 @@ import { call, ForkEffect, put, select, takeEvery, takeLatest } from 'redux-saga
import { ActiveBotHelper } from '../../ui/helpers/activeBotHelper';
import { generateHash } from '../helpers/botHelpers';
import { RootState } from '../store';
import { throwErrorFromResponse } from '../utils/throwErrorFromResponse';

import { SharedSagas } from './sharedSagas';
import { ChatSagas } from './chatSagas';
Expand Down Expand Up @@ -111,9 +112,7 @@ export class BotSagas {
};
let res: Response = yield ConversationService.startConversation(serverUrl, payload);
if (!res.ok) {
throw new Error(
`Error occurred while starting a new conversation: ${res.status}: ${res.statusText || 'No status text'}`
);
yield* throwErrorFromResponse('Error occurred while starting a new conversation', res);
}
const {
conversationId,
Expand All @@ -130,6 +129,8 @@ export class BotSagas {
mode: action.payload.mode,
msaAppId: action.payload.appId,
msaPassword: action.payload.appPassword,
speechKey: action.payload.speechKey,
speechRegion: action.payload.speechRegion,
user,
});

Expand All @@ -146,17 +147,15 @@ export class BotSagas {
// call emulator to report proper status to chat panel (listening / ngrok)
res = yield ConversationService.sendInitialLogReport(serverUrl, conversationId, action.payload.endpoint);
if (!res.ok) {
throw new Error(
`Error occurred while sending the initial log report: ${res.status}: ${res.statusText || 'No status text'}`
);
yield* throwErrorFromResponse('Error occurred while sending the initial log report', res);
}

// send CU or debug INSPECT message
res = yield ChatSagas.sendInitialActivity({ conversationId, members, mode: action.payload.mode });
if (!res.ok) {
throw new Error(
`Error occurred while sending the initial activity: ${res.status}: ${res.statusText || 'No status text'}`
);
if (!(action.payload.speechKey && action.payload.speechRegion)) {
res = yield ChatSagas.sendInitialActivity({ conversationId, members, mode: action.payload.mode });
if (!res.ok) {
yield* throwErrorFromResponse('Error occurred while sending the initial activity', res);
}
}

// remember the endpoint
Expand Down

0 comments on commit 49f2346

Please sign in to comment.