-
Notifications
You must be signed in to change notification settings - Fork 753
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
423 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ install: | |
- lerna bootstrap --hoist | ||
|
||
script: | ||
- npm run lint | ||
- npm run build | ||
- npm run test:coveralls | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# EAP Testing Instructions (Node Only) | ||
## Prerequisites | ||
EAP Testing assumes you have a bot deployed to Azure configured to use the Teams channel. | ||
## TL;DR | ||
1. install [ngrok](https://ngrok.com/) locally then cd to it's location in a terminal | ||
2. run ngrok `./ngrok http 3979 --host-header=localhost` | ||
3. Open your bot in the azure portal, select the `settings` blade and paste the ngrok url provided in the terminal then save. | ||
4. Clone the [BotBuilder-JS](https://github.com/Microsoft/botbuilder-js) repo | ||
5. `git checkout stevenic/4.4-planning` | ||
6. install lerna: `npm i -g lerna` then run `lerna bootstrap --hoist && npm run build` | ||
7. `cd samples/10. sidecarDebugging` and build using `npm run build` | ||
8. set your environment variables (prefix with EXPORT for mac, SET for windows): | ||
```bash | ||
PORT=3979; | ||
NODE_ENV=development; | ||
MICROSOFT_APP_ID=<your app id>; | ||
MICROSOFT_APP_PASSWORD=<your bot's password>; | ||
EMULATOR_URL=http://localhost:9000; | ||
``` | ||
9. Run your bot: `npm start` | ||
10. Open the Teams chat link provided in the azure portal in the channels blade. | ||
11. checkout the [Emulator](https://github.com/Microsoft/Botframework-emulator) branch`jwilaby/auto-connect-emulator`, build and run the Emulator as usual. | ||
12. In the Emulator, go to the view menu and select "Sidecar debug mode" the begin chatting with your bot in teams. | ||
# Run Your Bot in a Channel While Debugging Locally | ||
If you have configured your bot to [run in 1 or more channels](https://docs.microsoft.com/en-us/azure/bot-service/bot-service-manage-channels?view=azure-bot-service-4.0) and would like to test a locally running bot using the Emulator while interacting with it in a communication app (Teams, Skype, Slack, WebChat, etc.), these instructions will show you how. | ||
Since chat messages, adaptive cards, and other features have notable differences across the many available channels, the Emulator cannot reasonably account for all of them. This guide shows you how to have a locally running bot where changes can be made quickly, breakpoints can be set and the project can be rebuilt and restarted while interacting with it via an installed app like Teams or Slack. | ||
# How it works | ||
The tunneling software [ngrok](https://ngrok.com/) is used to create a tunnel to your locally running bot. The tunnel's URL is provided to your web app bot in Azure. You build your bot with an Emulator aware Adapter, run it locally then chat with it in Teams or any other available channel. The Emulator still receives the conversation's message exchange as usual. | ||
# Let's get Started | ||
If you haven't already, get the [latest Emulator](https://github.com/Microsoft/BotFramework-Emulator/releases), [ngrok](https://ngrok.com/) and update your bot's dependencies to use BotBuilder v4.4+ | ||
|
||
## 1. Update Your Bot's Code | ||
Your bot will need to become "Emulator Aware" in order to connect to and send the conversation exchange to the Emulator. Include the BotDebugger class somewhere in your bot's code: | ||
<img width="354" alt="image" src="https://user-images.githubusercontent.com/2652885/55196481-b5355580-516c-11e9-84dd-facae6c26528.png"> | ||
Then set the `EMULATOR_URL` environment variable to `http://localhost:9000` prior to launching your bot. On a mac, this is done using this command: | ||
```bash | ||
export EMULATOR_URL=http://localhost:9000 | ||
``` | ||
Alternatively, you can refer to documentation in [VS Code](https://code.visualstudio.com/docs/editor/variables-reference#_environment-variables) for setting up environment variables in the launch configs for your bot. | ||
## 2. Run ngrok | ||
Open a terminal and run ngrok with the following command to create a new tunnel: | ||
```bash | ||
./ngrok http 3979 --host-header=localhost | ||
``` | ||
The output in the terminal should look something like this: | ||
<img width="639" alt="image" src="https://user-images.githubusercontent.com/2652885/55196448-a2bb1c00-516c-11e9-87ce-98bdc1ebd7f8.png"> | ||
## 3. Update Azure to Point to the Tunnel | ||
In the azure portal, [navigate to your bot's settings](https://docs.microsoft.com/en-us/azure/bot-service/bot-service-manage-settings?view=azure-bot-service-4.0) and paste the | ||
url provided by the ngrok terminal in the *Messaging endpoint* field and save the changes. Do not forget to use `/api/messages`. It's best to create a Bot in Azure that is used specifically for this purpose. Do not overwrite | ||
the messaging endpoint of a deployed production bot. | ||
## 4. Connect to a Channel | ||
If you haven't already done so, [connect your bot to a channel](https://docs.microsoft.com/en-us/azure/bot-service/bot-service-manage-channels?view=azure-bot-service-4.0). You may also need to download and install the app | ||
associated with the channel if you have't already. | ||
## 5. Debug! | ||
Run your bot locally, then open the Emulator. In the Emulator choose file > Sidecar Debug Mode. | ||
<img width="357" alt="image" src="https://user-images.githubusercontent.com/2652885/55196498-c8482580-516c-11e9-8276-e660593197c4.png"> | ||
This will place the Emulator in a read only mode an enable inbound | ||
connections from your locally running bot. Begin chatting with your bot in Teams, Skype, Slack or WebChat. Once the first message is received, your bot will connect | ||
to the Emulator and send it the conversation exchange. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
packages/app/client/src/ui/editor/markdownPage/markdownElement.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. | ||
// | ||
// Microsoft Bot Framework: http://botframework.com | ||
// | ||
// Bot Framework Emulator Github: | ||
// https://github.com/Microsoft/BotFramwork-Emulator | ||
// | ||
// Copyright (c) Microsoft Corporation | ||
// All rights reserved. | ||
// | ||
// MIT License: | ||
// Permission is hereby granted, free of charge, to any person obtaining | ||
// a copy of this software and associated documentation files (the | ||
// "Software"), to deal in the Software without restriction, including | ||
// without limitation the rights to use, copy, modify, merge, publish, | ||
// distribute, sublicense, and/or sell copies of the Software, and to | ||
// permit persons to whom the Software is furnished to do so, subject to | ||
// the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be | ||
// included in all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, | ||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
// | ||
import { mount, ReactWrapper } from 'enzyme'; | ||
import * as React from 'react'; | ||
|
||
import { WelcomePage } from '../welcomePage/welcomePage'; | ||
|
||
import { MarkdownPage, MarkdownPageProps } from './markdownPage'; | ||
|
||
describe('The Markdown page', () => { | ||
let parent: ReactWrapper; | ||
let instance: WelcomePage; | ||
const render = (props: MarkdownPageProps) => { | ||
parent = mount<MarkdownPage>(<MarkdownPage {...props} />); | ||
instance = parent.instance() as WelcomePage; | ||
}; | ||
|
||
it('should render markdown when the user is online', () => { | ||
render({ onLine: true, markdown: '# markdown!' }); | ||
const divHtml = parent.html(); | ||
expect(divHtml).toBe('<div class="undefined "><div><div><h1>markdown!</h1>\n</div></div></div>'); | ||
}); | ||
|
||
it('should render offline content when the user is offline', () => { | ||
render({ onLine: false, markdown: '' }); | ||
const divHtml = parent.html(); | ||
expect(divHtml).toBe( | ||
'<div class="undefined "><div><div><h1>No Internet Connection</h1>try:<ul><li>Checking the network cables, model or router</li><li>Reconnecting to Wi-Fi</li></ul></div></div></div>' | ||
); | ||
}); | ||
|
||
it('should not update unless the props have changed and have different values', () => { | ||
render({ onLine: true, markdown: '# markdown!' }); | ||
const props = { ...instance.props }; | ||
expect(instance.shouldComponentUpdate(props, {}, {})).toBe(false); | ||
}); | ||
|
||
it('should render the "invalid markdown" message when invalid markdown is provided', () => { | ||
render({ onLine: true, markdown: [] as any }); | ||
const divHtml = parent.html(); | ||
expect(divHtml).toBe('<div class="undefined "><div><div># Error - Invalid markdown document</div></div></div>'); | ||
}); | ||
}); |
16 changes: 16 additions & 0 deletions
16
packages/app/client/src/ui/editor/markdownPage/markdownPage.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.offline { | ||
padding: 175px 20px 20px; | ||
position: relative; | ||
min-height: 450px; | ||
&::before { | ||
content: ''; | ||
position: absolute; | ||
left: 0; | ||
top: 0; | ||
width: 175px; | ||
height: 175px; | ||
-webkit-mask: url('../../media/ic_bot_framework.svg'); | ||
-webkit-mask-size: 175px; | ||
background-color: #007ACC; | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/app/client/src/ui/editor/markdownPage/markdownPage.scss.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// This is a generated file. Changes are likely to result in being overwritten | ||
export const offline: string; |
83 changes: 83 additions & 0 deletions
83
packages/app/client/src/ui/editor/markdownPage/markdownPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. | ||
// | ||
// Microsoft Bot Framework: http://botframework.com | ||
// | ||
// Bot Framework Emulator Github: | ||
// https://github.com/Microsoft/BotFramwork-Emulator | ||
// | ||
// Copyright (c) Microsoft Corporation | ||
// All rights reserved. | ||
// | ||
// MIT License: | ||
// Permission is hereby granted, free of charge, to any person obtaining | ||
// a copy of this software and associated documentation files (the | ||
// "Software"), to deal in the Software without restriction, including | ||
// without limitation the rights to use, copy, modify, merge, publish, | ||
// distribute, sublicense, and/or sell copies of the Software, and to | ||
// permit persons to whom the Software is furnished to do so, subject to | ||
// the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be | ||
// included in all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, | ||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
// | ||
import * as React from 'react'; | ||
import { Component } from 'react'; | ||
import MarkdownIt from 'markdown-it'; | ||
|
||
import { GenericDocument } from '../../layout'; | ||
|
||
import * as styles from './markdownPage.scss'; | ||
|
||
export interface MarkdownPageProps { | ||
markdown: string; | ||
onLine: boolean; | ||
} | ||
|
||
export class MarkdownPage extends Component<MarkdownPageProps> { | ||
private static markdownRenderer = new MarkdownIt(); | ||
|
||
private static renderMarkdown(markdown: string) { | ||
try { | ||
return this.markdownRenderer.render(markdown); | ||
} catch (e) { | ||
return '# Error - Invalid markdown document'; | ||
} | ||
} | ||
|
||
private static get offlineElement(): JSX.Element { | ||
return ( | ||
<div className={styles.offline}> | ||
<h1>No Internet Connection</h1> | ||
try: | ||
<ul> | ||
<li>Checking the network cables, model or router</li> | ||
<li>Reconnecting to Wi-Fi</li> | ||
</ul> | ||
</div> | ||
); | ||
} | ||
|
||
public shouldComponentUpdate(nextProps: Readonly<MarkdownPageProps> = {} as MarkdownPageProps): boolean { | ||
const props = this.props || ({} as MarkdownPageProps); | ||
return props.markdown !== nextProps.markdown || props.onLine !== nextProps.onLine; | ||
} | ||
|
||
public render() { | ||
const children = !this.props.onLine ? ( | ||
MarkdownPage.offlineElement | ||
) : ( | ||
<div dangerouslySetInnerHTML={{ __html: MarkdownPage.renderMarkdown(this.props.markdown) }} /> | ||
); | ||
return <GenericDocument>{children}</GenericDocument>; | ||
} | ||
} |
Oops, something went wrong.