This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActionProvider { | |
// The action provider receives createChatBotMessage which you can use to define the bots response, and | |
// the setState function that allows for manipulating the bots internal state. | |
constructor(createChatBotMessage, setStateFunc, createClientMessage) { | |
this.createChatBotMessage = createChatBotMessage; | |
this.setState = setStateFunc; | |
this.createClientMessage = createClientMessage | |
} | |
handleMessageParser = () => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MessageParser { | |
constructor(actionProvider, state) { | |
this.actionProvider = actionProvider; | |
// State represents the chatbot state and is passed | |
// in at initalization. You can use it to read chatbot state | |
// inside the messageParser | |
this.state = state | |
} | |
parse = (message) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import Chatbot from "react-chatbot-kit"; | |
import config from "./configs/chatbotConfig"; | |
import MessageParser from "./chatbot/MessageParser"; | |
import ActionProvider from "./chatbot/ActionProvider"; | |
function App() { | |
return ( | |
<div className="App"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const keys = document.querySelectorAll('.key'); | |
const audioNodes = document.querySelectorAll('audio'); | |
function getDataKey(key) { | |
let itemToAddClass; | |
keys.forEach(dataKeyItem => { | |
if (Number(dataKeyItem.dataset.key) === key) { | |
itemToAddClass = dataKeyItem; | |
} |
NewerOlder