FredrikOseberg / react-chatbot-kit

MIT License
301 stars 141 forks source link

Create User Chat Message Programatically #30

Closed dtcyad1 closed 3 years ago

dtcyad1 commented 3 years ago

Hi Fredrik,

Is it possible to create a User Chat Message? For example, in your example with learning options, you create a couple of buttons. Instead of firing the action directly, i want to submit that as a user message. So if the user clicked on the button called "JavaScript", then i want the user message to show as "JavaScript" in the chatbot - which can then be processed by the Message Parser in the normal way (and call the required action).

Thanks

dtcyad1 commented 3 years ago

Hi Fredrik,

Got it to work in the ActionProvider. I was using an older version of the AP where the createClientMessage was not being passed in my constructor. You may close this issue.

Thanks

alanmrochadeveloper commented 3 years ago

Similar issue. on widget: image on ActionProvider: image

error: image

this.createChatBotMessage(message) works but this.createClientMessage(message) doesn't Is there a reason why? It says createClientMessage is not a function, using typeof it says it is undefined! PS: I'm using typescript, most of the types are "any" for tests purposes!

alanmrochadeveloper commented 3 years ago

My mistake. A silly one. Well, just fixed it. image I was passing a 3rd constructor parameter as "setStep" in place of "createClientMessage, and the 4th parameter is undefined, so I fixed it by removing the 4th parameter and placing createClientMessage in the right place.

vahidsavabieh commented 1 year ago

My ActionProvider is functional, but I cannot have a constructor . import createClientMessage from library . When I use createClientMessage show the user message, it does not parse properly.