Transport data from service dialog to state machine

Hi there,

we are using a generic service dialog to trigger a state machine. However, we are assembling some hashes with the help of user input which needs to be transferred to the state machine.

There are several approaches and we didn’t get one of it working by now:

  • Saving the data in a hidden service dialog field. Problem here is that we gather some data with a dynamic dialog field which returns some results back to the user but there is additional data that cannot be presented to the user and would require an additional dialog field. But how do we save data in another dialog field is it possible?
  • Saving the data somewhere in $evm space. Is there some place in $evm like $evm.root[‘cache’] or something else where I can put some data to read it later on from state machine?
  • Saving data to the filesystem. We could serialise the data to json and save it on the filesystem. We did not test this option by now.

What do you think about the approaches? Is there a better way that we didn’t think of?

Kind Regards

We usually serialize the data to JSON, store it in a state_var and parse it again when we need it

I am not sure if I understand the problem correctly, but you want to calculate some value, while you are still displaying the ServiceDialog and access that value later from the StateMachine?
Can’t you just redo the Calulation from the StateMachine?

Hi buc,

thank you very much for your reply.

We usually serialize the data to JSON, store it in a state_var and parse it again when we need it

My understanding is that we cannot use state_vars in a service dialog. Is that correct?

I am not sure if I understand the problem correctly, but you want to calculate some value, while you are still displaying the ServiceDialog and access that value later from the StateMachine?

Correct.

Can’t you just redo the Calulation from the StateMachine?

That is a interesting idea. Of course, we have the option to recalculate in state machine. The calculation is about datastores of a infrastructure provider. So if the situation on the infrastructure changes between time when the service dialog is opened and when the state machine runs the result of the calculation might differ.
I admit that the chance of calculation difference is very low but nonetheless this is the reason why I’d like to avoid recalculation.

Greetings

We have one use-case where we use memcached to store an intermediate result outside the StateMachine.

  • Create a unique identifier everytime the dialog is displayed in dialog_uid
  • Do you calculation in the dialog_calc and store the result in memchaced (including dialog_uid)
  • In the StateMachine you can read dialog_uid and ask memcached for the calculated value

If memcached doesn’t work you can also create a Generic Object in the Database, but you will need to cleanup everytime the user selects cancel on the dialog

Wow, those are two very promising suggestions.

I mean we are working with generic objects. We didn’t think of using them in this context before. We should give them a try.

Many thanks.

Let me know if it worked