Chatbot

A simple chatbot component with customisable flow.

A chatbot component with customisable flow

Open in

Installation

npx shadcn@latest add https://shadfinity.sanjaybora.in/registry/chatbot.json

Props

PropTypeDescription
namestringThe chatbot's display name.
imagestring (URL)The chatbot's avatar image.
initialStepstringThe first step in the chatbot flow.
tooltipstringTooltip text displayed with widgit.
defaultOpenbooleanControls chatbot's initial visibility.
flowFlowNode[]Defines chatbot conversation logic.

FlowNode

Each flow node in the chatbot has the following properties:

PropertyTypeDescription
delaynumber (ms)Delay before showing the message.
messagestringThe message displayed to the user.
optionsstring[]List of selectable responses.
render()(onSubmit)=>ReactNodeUsed to render custom components, to submit and move to next step, use the onSubmit function, pass the string value and it will be available in validation and next function. (for example, check out the example code given above)
inputboxDisabledbooleanDisables the input field.
validationfunctionFunction to validate user input. Must return a boolean or string.
nextstring | functionDefines the next step in flow. Can be a string or a function that determines the next step based on input.
autoNextbooleanAutomatically moves to next step after displaying the message.