// Function to send event query to server async df_event_query(event) { const res = await axios.post("/api/df_event_query", { event, userID: cookies.get("userID") }); // Iterating over all the responeses in the the request response // because the chatbot can have multiple responses for a single phrase for (let msg of res.data.fulfillmentMessages) { let says = { speaks: "bot", message: msg }; this.setState({ messages: [...this.state.messages, says] }); } this.sound.play(); }
constructor(props) { super(props); // This binding is necessary to make `this` work in the callback this._handleInputKeyPress = this._handleInputKeyPress.bind(this); this._handleQuickReplyPayload = this._handleQuickReplyPayload.bind(this); this.hide = this.hide.bind(this); this.show = this.show.bind(this); this.state = { messages: [], showBot: true, shopWelcomeSent: false, clientToken: false, regenerateToken: 0 }; if (cookies.get('userID') === undefined) { cookies.set('userID', uuid(), { path: '/' }); } }
componentDidMount() { this.setState({ type: this.props.location.state !== undefined ? this.props.location.state.item : "newbadge" }); let load = cookie.get("load"); // cookie.remove('load') if (load !== "done") { cookie.set("load", "done", { maxAge: 86400 }); this.setState( { showLoading: true }, () => { setTimeout(() => { this.setState({ showLoading: false }); }, 2500); } ); } else { this.setState({ showLoading: false }); } }
constructor(props) { super(props); this.state = { messages: [], showBot: false, welcomeSent: false, botName: 'Chatbot' }; this.sound = new Audio(messageSound); //Setting the cookie using uuid if (!cookies.get("userID")) { cookies.set("userID", uuid(), { path: "/" }); } //Binding event listeners this.toggleBot = this.toggleBot.bind(this); this._handleInputKeyPress = this._handleInputKeyPress.bind(this); }
constructor(props) { super(props); this.state = { messages: [], showBot: false, welcomeSent: false, botName: 'Chatbot' }; this.sound = new Audio(messageSound); //Setting the cookie using uuid if (!cookies.get("userID")) { cookies.set("userID", uuid(), { path: "/" }); } //Binding event listeners this.toggleBot = this.toggleBot.bind(this); this._handleInputKeyPress = this._handleInputKeyPress.bind(this); }
// Function to send event query to server async df_event_query(event) { const res = await axios.post("/api/df_event_query", { event, userID: cookies.get("userID") }); // Iterating over all the responeses in the the request response // because the chatbot can have multiple responses for a single phrase for (let msg of res.data.fulfillmentMessages) { let says = { speaks: "bot", message: msg }; this.setState({ messages: [...this.state.messages, says] }); } this.sound.play(); }