1

I am using react chat widget as frontend and I want to connect it to botpress as the backend for functioning. I have a function in my app.js file. handleNewUserMessage is the function responsible to hit botpress and getback the response.

Here is the code in react:

    handleNewUserMessage = (newMessage) => {    
    toggleMsgLoader();
    setTimeout(() => {
      toggleMsgLoader();      
      if (newMessage === 'fruits') {
        setQuickButtons([ { label: 'Apple', value: 'apple' }, { label: 'Orange', value: 'orange' }, { label: 'Pear', value: 'pear' }, { label: 'Banana', value: 'banana' } ]);
      } else {
        addResponseMessage(newMessage);
      }
    }, 2000);
theduck
  • 2,589
  • 13
  • 17
  • 23

0 Answers0