Here's an example:
Every time a user sells a car, he has to reply to my system to say what the color of the car is that he sold (my system knows that a car was sold and what its make is but not what color it was).
If the user sells only 1 car at a time and texts back immediately, I can remember which car he is talking about by storing information about the current_car in a session variable. If, on the other hand, the user sells 3 cars simultaneously, I can't store a current_car session variable because there are 3 current cars.
How do I know which car the user is talking about when he replies to my text? Is there any way to embed a unique token in the text message I send so that the reply references the correct car out of the 3 cars?
Twilio API doesn't support that. Have you noticed what Twitter does for the same precise use-case? They include in the original SMS instructions such as "reply directly with ....". The user would have to type that in so keep it simple.
Alternatively, you can reply to the ambiguous messages with "There were three cars. Which sold? (reply with number 1, 2, or 3)"
Related
I am trying to make small POS system, using FDMem table to fill items for the customer.
In case the customer forget his money or go to change a product .. and the customers in the line move and new customer shows up asking to start sale process, how can I save or freeze the current state of the FDMem table holding the products of the previous customer and start a new order and finish the sale. Then, when the first customer comes back, how can I resume the previous sales process and reactivate the previous FDMem table with it's items?
Add one more column in the FDMem table. That column could take 3 values: 'Finalized', 'Opened' and 'Paused' depending how the "status" of the sales is going. You can then navigate between the records.
So if I understand you correctly you want to be able to handle multiple customers or orders at the same time.
One solution one would guess would be to assign each customer unique number and them add that number as additional field to each record in your database. Now assigning unique values to online customers isn't particularly difficult. In fact you already have such information in form of session ID. But doing something like this for customers in a physical store is not feasible.
But there is another similar solution. Most Tax authorities require any shops to issue a receipt for any purchase made. And each of those receipts needs to have a unique number. So you could reserve a new receipt number when customer gets to your POS for the first time and you start adding its items to the system. Then you might want to have another table with all reserved receipt numbers and their current status, so you can know which receipt has been finished which one is still pending completion or which one was cancelled.
I probably could not find anything about this because I don't know how to describe it.
I have the following setup:
A user account can have a profile with basic information (name, age), optional and there can also be a profile without associated account.
A profile can be linked to several gameprofiles (one for each game)
A gameprofile has an ingame name and should be where I can find a player's statistics.
Now, for different games, there are different statistics. Do I really need to create another model for each game with the associated attributes or is there a smarter way to do this?
#Okomikeruko makes a good point about different game stats described by different attributes. You should be warned though that hash in string approach will complicate querying and indexing this table.
Alternative is to have two tables for keeping game stats, one being the header table, carrying attributes such as game session dates, duration, etc. and the detail table, keeping the game-specific attributes:
# pseudocode:
GameProfile
has_many :game_profile_details
end
GameProfileDetail
belongs_to :game_profile
stat_name: string
stat_value: string
end
You could create a generic model that holds the statistics for a given game.
Since each game would have some stats that are identical (name?, high score?) you could set those up easily.
The tricky part would be how to handle different game stats. One game might have a "best time" while another "turns used".
To handle this, you could save other data as a hash in a string.
So it would save meta_data: "{'best_time' => '0:04:23.6', 'other' => 'thing'}" in one game but you wouldn't need to leave an empty best_time field for games that don't use one.
Then when you load the data, based on the game, you could code
<%= #gamedata.meta_data.best_time %>
# returns "0:04:23.6"
I have a requirement where i need to save the contacts of the user and i have the following issues.
I have a user table where i would save the "user1" and i also the save the users in his contact in the same table.
And say another user "user2" has to be saved along with his contacts in user table. Consider "user2" has few contacts same as "user1"(i.e., the contact number is same but the naming is different). And i should not repeat the user who is already present. In this case i can check with contact number so if that contact number is already present i can skip saving the contact and use that id instead.
But another situation is, consider "user1" has saved his contact as "9999444494" and "user2" also has "9999444494" but they both belongs to different country say "country code +91 and +92 respectively" but it looks as if the contacts were same if they do not specify the country code and how could i get these differentiations and save it in the table.
I am stuck with this issue. Please help me. Thanks in advance.
There is no reason to assume that just because two people have the same phone number, that they will change that phone number at the same time.
Say your two users are employees of the same company and they give the main switchboard number as their contact number. When one quits the company their contact info will change but the other will stay the same. The same could happen if your users are members of a family who share a phone. When one leaves (child moves out, parents divorce,...) the contact numbers for each user will be different.
Therefore: don't try to rationalize contact numbers down to a single record. Repeated entries are not the same as duplicate entries when that repetition is coincidental.
Regarding country code, you need to include that in your contact information in either the same column or a separate column. If that country code is nullable then keeping it separately might be helpful so that you can see plainly that the information is missing.
After finishing Michael Hartl's tutorial on Rails, my first pet project is building a call tracking app using the Twilio API. The basic idea is the following -
There are 4 plans users can sign up for, which limit the number of phone numbers they have, and the number of minutes they can use
Each user, once registered gets their own subaccount from Twilio
Each user can buy phone numbers, limited to their plan
Each user can track what's happening on their phone numbers.
Right now, I've build a basic authorization system, and brainstormed a potential data structure. I have huge loop holes in understanding though, so an experienced programmer's eyes would be greatly appreciated. I.e is there a better data structure, does what I outline below even make sense?
---So, here's the data structure
Table : Plans
max_phone_numbers: integer
max_minutes: integer
has_many: users
Table : Users
name:string
email:string
password_digest:string
remember_token:string [For log in system]
Twilio_SubAccountSid: string
Twilio_SubAccountAuthToken: string
Plan id : integer [to connect to plan]
stripe_token : string [for charging]
belongs_to: plan
has_many: phone_numbers
Table : Phone Numbers
belongs_to users
phone_number:string
user_id: integer
has_many: data_points
Table : Twilio Data
belongs_to phone_numbers
phone_number_id: string
[All of Twilio's call tracking data..i.e duration of call, location etc.]
Okay, that's pretty much my interpration of how it might work. Please tear it apart!
In terms of the data structure, I think this seems to be it. What I didn't realize though is that there's a lot more controllers involved. For example, searching and buying in Twilio involved two CREATE actions, so I had to make another controller. I imagine there would be another controller that would be responsible for routing calls.
We are implementing edi order processing and are currently about to check how we set up the interface.
Usually a order may carry multiple positions. For our customer it seems that an incoming order may need to be split up in multiple orders if they will be manufactured in different factories due to erp system requirements.
For me its sounds confusing if a customer does one order and gets back 3 different order numbers. One solution could be one position per order policy, however this increases the number of orders even when not needed.
The customer is sending an "ORDERS" message and will receive an order confirmation "ORDRSP".
I'm wondering whats the common solution to solve this problem? Manually keeping track of the sub orders thems to be no option has they are confirmed at different times, etc..
different solutions:
You split up orders: retailer will receive different shipments, different ASN's, etc (all referring to the same RetailersOrderNumber). But...not all retailers want this/can handle this.
Retailer splits up the orders (in most cases this means you will be 3 different manufacturers in their system ;-)
Factories deliver to one (manufacturers) DC where all the order/shipment handling is done.
(AFAIK these are the possibilities....)
kind regards, henk-jan