I'm trying to add autosuggestion/autocomplete function in my bot-framework web chat(v-4) using react js. In which i want to fetch input data from azure table. Heard that its not recommended to use j-query inside React js. Looking for a solution to add this.
I'm looking for a solution like in the below image, PFA.
And the code which i used for React is attached below,
React.js file
import React from 'react';
import { DirectLine, ConnectionStatus } from 'botframework-directlinejs';
import ReactWebChat from 'botframework-webchat';
import './ChatComponent.css';
export default class extends React.Component {
constructor(props) {
super(props);
this.state = {
token: '',
conversationId:'',
directLine: {},
view: false,
feedBack: null,
value: '',
popupContent: '',
storeValue:''
};
this.handleTokenGeneration = this.handleTokenGeneration.bind(this);
this.handleChange = this.handleChange.bind(this);
}
handleTokenGeneration = async () => {
console.log("handleTokenGeneration");
const response = await fetch(`api/TokenGenerationService/GetToken`);
const data = await response.json();
this.setState({ token: data.categoryObject.token, conversationId: data.categoryObject.conversationId });
console.log("conversationId");
};
async componentDidMount() {
try {
await this.handleTokenGeneration();
} catch (error) {
console.log("error in fetchung token");
console.log(error);
}
this.state.directLine = new DirectLine({ token: this.state.token });
this.setState({ view: true });
}
handleChange = (event) => {
this.setState({ value: event.target.value });
}
render() {
if (!this.state.view) {
return <div />
} else {
return (
<div className="react-container webchat" >
<ReactWebChat directLine={this.state.directLine} webSocket={true} userID='2656' username='res' store={this.state.storeValue} />
<footer className="chat-footer" >
<div className="foot-footer">
Was I helpful ?
<span className="feedback" >Yes</span><span>|</span><span className="feedback" >No</span>
</div>
</footer>
</div>
);
}
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…