The example shows the use of the botbuilder-js
SDKs for the browser using the BotFramework-WebChat and a custom WebChatAdapter.
After running the bot, to see it in action, visit http://localhost:8080
.
- Clone the repository
git clone https://github.com/microsoft/botbuilder-samples.git
- In a terminal, navigate to samples/javascript_es6/01.a.browser-echo
cd samples/javascript_es6/01.a.browser-echo
- Install modules and start the bot
npm i & npm start
- To see the bot in action, visit
http://localhost:8080
in a browser.
Developers can use the BotAdapter abstract base class to implement their own custom adapters. Implementing a custom adapter allows users to connect bots to channels not supported by the Bot Framework. In this sample, a custom WebChatAdapter has been implemented so that the entirety of the bot is hosted in a user's browser.
Hosting a bot in the browser provides these benefits:
- A bot hosted in the user's browser has improved latency as there is no round-trip from the browser to a server hosting the bot.
- One engineering team in charge of bot design and the website. This can lead towards a more integrated UX and speed up development.
- A browser hosted bot can offload some of the work done by your servers by passing it to the user's machine.