conversational-form
conversational-form copied to clipboard
remapTagsAndStartFrom and flowCallback
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
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.
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:
- initial steps
- the user reaches a question where he may choose among 5 answers ("categories")
- in the callback a calculation is being done based on all previous steps
- I use addRobotChatResponse to send an appropriate message based on the calculation
- i ask the user "is this ok or do you want to change category?
- if "change category" then "goto 2" :D
simulating the click on the 2. actually causes inconsistencies as you indicated
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 I'll try to investigate and give you a decent answer later in the week.
@stormsson circling back to this. Did you manage to solve your issue?
Hello , have you recently found a solution to this problem?
sorry didn't read the notification, sadly i did not find a solution