BotFramework-DirectLineJS | JavaScript client library for Microsoft Bot Framework | Bot library
kandi X-RAY | BotFramework-DirectLineJS Summary
kandi X-RAY | BotFramework-DirectLineJS Summary
Client library for the Microsoft Bot Framework Direct Line protocol. Used by WebChat and thus (by extension) Emulator, WebChat channel, and Azure Bot Service.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of BotFramework-DirectLineJS
BotFramework-DirectLineJS Key Features
BotFramework-DirectLineJS Examples and Code Snippets
Community Discussions
Trending Discussions on BotFramework-DirectLineJS
QUESTION
I am passing getResponse()
function in the useEffect with userInput
as dependency array. Everytime a user sends input this function is triggered and I get new directline object created everytime. Problem I am facing is that I am creating bot everytime I send a request to bot. How can I create an object only once on initial render and then use the object to connect with bot.
Please help!
Here's the botframework documentation I am following
Here's the code I wrote to communicate with bot in ReactJS.
...ANSWER
Answered 2021-Nov-19 at 00:29You should move the creation of the DirectLine client
object, as well as subscribing to activity
and connectionStatus
, out of the function or configure the useEffect() hook to run only once. The client
object should be created once and then referenced, as needed. Check out this SO post that discusses how to implement these options.
Additionally, because you already subscribe to activity
and connectionStatus
, these should be allowed to run independently so they can function as expected. When the connectionStatus
changes, the switch statement will detect this. As the different cases are met, you could assign the status thru useState()
and detect the changes to state thru the useEffect()
hook.
QUESTION
I am new to react js and i want to call chatbot using directline token. I have the code given below. My need is to call the chatbot when the button is clicked and must get minimzed. I don't know how to do that and this appears to be a simple question. Help me in resolving it. Thanks in advance.
...ANSWER
Answered 2020-Feb-03 at 10:20You can follow this sample provided by Microsoft. It is a good starting point for the features you're asking for (minimizing the chat window). Basically, you create a these two React components:
MinimizableWebChat.js & WebChat.js
I won't be going through the code since the README of the sample has a detailed description of the implementation. But in MinimizableWebChat.js you handle the creation of the store, handling the fetching of the token, and the handling of the minimization. In WebChat.js you can use the createStyleSet method to customize the WebChat as you wish. You can see all the properties you can set from that method here. I hope I was able to help you.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install BotFramework-DirectLineJS
npm install
npm run build (or npm run watch to rebuild on every change, or npm run prepublishOnly to build production)
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page