-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use with React #32
Comments
Hello, the "website.js" is not a react component. |
Hi Anton! I don't fully understand. Does that mean that in order to use Recast AI as a react component I have to build my entire React app around this repo?? On the other hand I already tried running in the past the app to see if it does indeed work but when I run npm start it executes this script: "start": "npm run clean:dist && node bin/build-dev" (as defined in package.json), and it simply gets stuck in ' Waiting for changes... ', the app doesn't start on any port so I couldn't even test it. Any ideas? I hope I was clear enough. Thanks for your support!! |
Hello, "npm start" is only a script to build the webchat component. It means that everytime you make a change in the /src folder, it will re-build a "webchat.js" in the /dist folder. You can see the change by opening index.html on your web browser. |
Mystery solved, the trick is to open the I was looking for the serving port everywhere in the repo lol, I would highly recommend to add this in the |
Hi TianyuanC! Could you elaborate? I can see that if I clone the repo, enter mi channelID and token in the html script of the cai, then I run npm start and open index.html then yes, I can see the chatbot. To be able to continue developing the app as a normal react app is where I fail. Have you managed to achieve that? |
Hi @turutupa It would be ideal if we can export But for me, I will probably need to customize the styles a lot to integrate into existing projects, so I will focus on Question for @antoncazalet , just curious, do we have plans to publish this awesome react control as public npm packages (also a control with the Fiori style would be perfect lol). Thanks! |
What I was thinking is, the chat component is being rendered in Cai div (you can see it in script.js), I will probably create a new div in the html and render the rest of my react app there. I think it is difficult for them to extract it as an npm package due to the dependencies it relies on, but perhaps could be done, idk |
The webchat could be on npm but I don't think anyone will publish it. A lot of features in this webchat is missing and it's also outdated. |
Ok so I manged to get it working but it not a very nice way. I still haven't tested how to do it without having to manually open the html, will check that later. On the meantime I added this in script.js: It is basically a fast way to get it working. Perhaps this belongs to a different post but: is there a method when using CAI as React component to access the Bot Memory??? I see you can get the last message with the getLastMessage prop. Is there something similar?? Thanks in advance! |
Hi everyone!
How can I use it as a React Component??
I have cloned the repo ( https://github.com/SAPConversationalAI/Webchat ) -> npm install -> npm run build , and then.. what next? I thought I could copy the generated webchat.js file in the ‘dist’ folder into my own React app and import it as CaiWebchat from ‘webchat’, like mentioned in github and that would be it.
But I get the following error: ‘Attempted import error: ‘./webchat’ does not contain a default export (imported as ‘CaiWebchat’).'
Even if I try to call a script in the main html page but in src I point it to this webchat.js I get Unexpected token <..
Something I am not doing right.
Has anyone managed to make it work?? Can you point me in some direction?
Thanks in advance!
The text was updated successfully, but these errors were encountered: