Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabled communication with remote Direct Line Speech bots #2079

Merged
merged 5 commits into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
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.

48 changes: 34 additions & 14 deletions packages/app/client/src/state/sagas/botSagas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,18 @@ 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(
new Error(
'Error occurred while starting a new conversation 500 INTERNAL SERVER ERROR: Cannot read property "id" of undefined.'
)
);
}
});

Expand Down Expand Up @@ -323,15 +329,22 @@ 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(
new Error(
'Error occurred while sending the initial log report 500 INTERNAL SERVER ERROR: Could not read property "id" of undefined.'
)
);
}
});

Expand Down Expand Up @@ -377,15 +390,22 @@ 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(
new Error(
'Error occurred while sending the initial activity 500 INTERNAL SERVER ERROR: Could not read property "id" of undefined.'
)
);
}
});
});
21 changes: 10 additions & 11 deletions packages/app/client/src/state/sagas/botSagas.ts
Original file line number Diff line number Diff line change
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
Loading