I have been looking for a way to organize an USSD application without success, I have so many unanswered questions making me basically stalled. I have read many questions on stackoverflow about state machine pattern or strategy pattern but it's still blur in my mind.
Let's say I have a ussd application to provide the following contrived services:
1 - get free joke
2 - register for paid joke (ie 10 jokes/day)
3 - get balance for paid joke (remaining )
Under 1 I have other options like categories :
1 - satire
2 - nerdy
3 - explicit
Under 2 I could have options like:
1 - tumblr
2 - yahoo
3 - hotmail
Under 2-1 for example it can show payment options like :
1 - paypal
2 - stipe
Then under 2-1-1 , it can ask for email, then password or so etc.
This can get other nested structure where some payment method are enabled for some vendors or not etc.
Problem 1 Considering USSD provider uses POST expect us to use a REST webservice to receive input from users' phone. This is server making API call to another server. How can session been used to pass information between requests. USSD can result is long conversation(back and forth ) with server. how is session maintained ? cookie (client is not a browser) or database? (sails has support for redis and mongo session storage).But again which mechanism is used to ID each request. That's one fuzzy area I am struggling with.
Problem 2 If problem 1 is solved how to apply it to the application. I mean by that say, user chooses flow 2 by typing number 2 on phone, the app UssdrouteController got the input 2 and send the request to RegisterpaidjokeController to process. How is RegisterpaidjokeController is going to differentiate between first number 2 and maybe second number which means yahoo option? How UssdrouteController doesn't confuse this with flow 1 option 2 which is nerdy category. I would like to find a way not to hard code this and track user's progress in each flow. This assumes some session is used. how to document this flow and make it maintainable. It's all confusing for me.
I would be most grateful if I could get some pointers around this. Thanks in advance