Skip to content
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

Dynamic 'Delay' for step #368

Open
tatianafrank opened this issue Feb 2, 2023 · 0 comments
Open

Dynamic 'Delay' for step #368

tatianafrank opened this issue Feb 2, 2023 · 0 comments

Comments

@tatianafrank
Copy link

I have a range slider so that the user can control the speed of the messages however when the state changes, the delay for the step doesn't update.
UseSlider function below is using context/reducer to manage state for the slider value which ranges from 1 to 6 and then gets multiplied by 1000 for milliseconds to seconds conversion. It's pulling the initial value but step delay value is not updating when the context changes even though I can see in the logs that the state is definitely changing.
Is there some way where I can dynamically change the 'delay' value for steps in the bot?

{
  export default function ChatPrototype() {
    const { sliderValue } = useSlider();

    return (
      <div className='chatBotContainer'>
        <ChatBot 
         steps={[
              {
                  id:'1', 
                  message: "Welcome!  It is hoped this will be a wonderful experience for you.", 
                  trigger:'2',
             },
             {
              id:'2', 
              message: "May I know your name, please?", 
              trigger:'name',
             },
             {
              id:'name',
              user: true,
              trigger: '4',
             },
             {
              id: '4',
              message: ({previousValue, steps}) => `Hi, ${previousValue}. I'm a chatbot, a software program. I use the name 'Riley'.`,
              trigger: 'intro_1',
             },
             {
              id: 'intro_1',
              component: <Intro1 />,
              waitAction: true,
              asMessage: true,
              hideInput: true,
              delay: (sliderValue *1000),
             },
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant