Skip to content

Instantly share code, notes, and snippets.

View FredrikOseberg's full-sized avatar

Fredrik Strand Oseberg FredrikOseberg

View GitHub Profile
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,
// MessageParser starter code
class MessageParser {
constructor(actionProvider, state) {
this.actionProvider = actionProvider;
this.state = state;
}
parse(message) {
console.log(message)
}
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
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 = () => {