const deleteCookie = name => cookies.remove(name)
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(); }
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); }