conversational-form icon indicating copy to clipboard operation
conversational-form copied to clipboard

remapTagsAndStartFrom and flowCallback

Open stormsson opened this issue 5 years ago • 7 comments

I am probably using this in the wrong way, I have configured the cf in order to have an html form with questions, and manage the flow via a custom function.

I configured the flowCallback, and i would like to restart the flow from a previous question if a specific answer is met.

inside the flowCallback i have this:

    if(answers["q3"][0] == "alter_flow") {
     console.log("changing flow")  
      window.cfInstance.remapTagsAndStartFrom(1, false, false)
    }

but it would seem that something is wrong with this approach (see codepen for full code) . https://codepen.io/anon/pen/JVXzPL

am I doing something wrong?

thank you for this tool

note, the odd behavior become visible after clicking the first time "alter flow" :

  • some times the previous question is repeated
  • some times the previous quesiton is not present
  • when reaching again the question with "alter flow" button, it will not work anymore

stormsson avatar Apr 05 '19 10:04 stormsson

Hi @stormsson. Your approach was not far off. I tweaked your conditional a bit. However, it seems to cause issues when you try to jump to a different question before the current one has been answered. I don't have an answer for you right here and now. Could you use conditionals instead to achieve the desired outcome?

Edit: Here's my approach. I tried to imitate a click on the answer in question but it still causes issues - likely because we are messing with the flow mid way. We try to jump to question 0 right before a question is answered. Remember, the natural flow is to jump to the next question after an answer. That is why the jump is inconsistent.

jenssogaard avatar Apr 05 '19 12:04 jenssogaard

Hi @jenssogaard thank you again for your help, I really need to send you a coffee somehow 😄 I don't know actually how to achieve the same result with conditionals:

My current flow is:

  1. initial steps
  2. the user reaches a question where he may choose among 5 answers ("categories")
  3. in the callback a calculation is being done based on all previous steps
  4. I use addRobotChatResponse to send an appropriate message based on the calculation
  5. i ask the user "is this ok or do you want to change category?
  6. if "change category" then "goto 2" :D

simulating the click on the 2. actually causes inconsistencies as you indicated

stormsson avatar Apr 05 '19 13:04 stormsson

i have not clear what remapTagsAndStartFrom is for ,then :(

edit: by using window.cfInstance.flowManager.maxSteps +1 and addTags a part of the functionality seems resolved. now the only missing step is the possibility to "unset" a specific value to a specific tag already set in the past. Is there a hook, or some internal that i could use ?

re-edit @jenssogaard you mention that the problem is due to the fact that we jump before answering the question, what about jumping after the answer? could this be possible ?

thank you again

stormsson avatar Apr 07 '19 17:04 stormsson

@stormsson I'll try to investigate and give you a decent answer later in the week.

jenssogaard avatar Apr 08 '19 00:04 jenssogaard

@stormsson circling back to this. Did you manage to solve your issue?

jenssogaard avatar May 30 '19 14:05 jenssogaard

Hello , have you recently found a solution to this problem?

Doss12 avatar Jul 18 '19 08:07 Doss12

sorry didn't read the notification, sadly i did not find a solution

stormsson avatar Jul 20 '19 07:07 stormsson