Skip to content

Instantly share code, notes, and snippets.

@FredrikOseberg
Last active August 18, 2023 07:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FredrikOseberg/7fad0e5c1458559c544de6f0dd41e602 to your computer and use it in GitHub Desktop.
Save FredrikOseberg/7fad0e5c1458559c544de6f0dd41e602 to your computer and use it in GitHub Desktop.
// 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 = {
...,
state: {
gist: "",
},
widgets: [
{
widgetName: "overview",
widgetFunc: (props) => <Overview {...props} />,
mapStateToProps: ["gist"],
props: {}
},
{
widgetName: "messageParser",
widgetFunc: (props) => <MessageParser {...props} />,
mapStateToProps: ["gist"],
props: {}
},
{
widgetName: "actionProviderDocs",
widgetFunc: (props) => <ActionProviderDocs {...props} />,
mapStateToProps: ["gist"],
props: {}
},
],
};
export default config;
// Use the widget in actionProvider
this.createChatBotMessage("Hi", { widget: "overview" })
@PeterTF656
Copy link

Has anybody tried to implement an image uploading widget? How does that work with this package?

@FredrikOseberg
Copy link
Author

Has anybody tried to implement an image uploading widget? How does that work with this package?

Should be pretty straight forward as you just implement a regular react component as widgets. Or did you have another use case in mind?

@PeterTF656
Copy link

Thank you for your quick response, Sir! Yep, I have a functional flask python backend, with NLP and CV models in it, so now, I'm sending each user input to the flask backend using a "POST" request, and the chatbot front end receives each response from the backend. For texts (strings), it's straightforward (currently I'm accessing user input in the state), but for image files, I imagine maybe they should be handled differently in MessagePraser or somewhere along the process? And lastly, I probably should create another function in the ActionProvider for Posting multipart and form-data.

@GauravB7
Copy link

How to show date before every message and add props to widget?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment