This file contains 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
// MessageParser starter code | |
class MessageParser { | |
constructor(actionProvider, state) { | |
this.actionProvider = actionProvider; | |
this.state = state; | |
} | |
parse(message) { | |
console.log(message) | |
} |
This file contains 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 { createChatBotMessage } from "react-chatbot-kit"; | |
import SingleFlight from './components/SingleFlight/SingleFlight' | |
const botName = "Somebot"; | |
const config = { | |
// Defines the chatbot name | |
botName: botName, |
This file contains 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
// in config | |
... | |
import Overview from "../components/widgets/Overview/Overview"; | |
import MessageParser from "../components/widgets/MessageParser/MessageParser"; | |
import ActionProviderDocs from "../components/widgets/ActionProvider/ActionProviderDocs"; | |
const config = { | |
..., |
This file contains 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 | |
} | |
reset = () => { |
This file contains 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 { createChatBotMessage } from "react-chatbot-kit"; | |
import Overview from "../components/widgets/Overview/Overview"; | |
import MessageParser from "../components/widgets/MessageParser/MessageParser"; | |
import ActionProviderDocs from "../components/widgets/ActionProvider/ActionProviderDocs"; | |
const botName = "DocsBot"; | |
const config = { |
This file contains 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 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 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 fetch = (url, options) => { | |
// simplified | |
return new Promise((resolve, reject) => { | |
const xhr = new XMLHttpRequest() | |
// ... make request | |
xhr.onload = () => { | |
const options = { | |
status: xhr.status, | |
statusText: xhr.statusText |
This file contains 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
createChatBotMessage("Thanks, I'll see what I can find", { | |
widget: "rentalCarResults", | |
withAvatar: true, | |
delay: 500 | |
}) |
This file contains 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 Overview from "../components/widgets/Overview/Overview"; | |
import MessageParserDocs from "../components/widgets/docs/MessageParserDocs/MessageParserDocs"; | |
const config = { | |
..., | |
state: { | |
gist: "", | |
infoBox: "", | |
}, | |
widgets: [ |
NewerOlder