Reputation: 1631
I am creating a chat application with twilio but having an issue tracking conversations among multiple users and multiple conversations.
Example:
conversation -> userA & userB
conversation2 -> userA & userB
When userA sends a message to userB in conversation2 when I receive a SMS message from userA how do I map it to conversation2?
What I am expecting:
What I am looking for is an ID that is either provided by me or generated by twilio and given to me when I send the SMS. Then when I receive a SMS from twilio I can match it to a conversation by looking at the ID stored when the SMS was sent.
thank you!
Upvotes: 3
Views: 1253
Reputation: 1
I know this response may be too late, but here goes anyway...
Conceivably, if Conversation 1 and Conversation 2 both are between different parties. You could create a mapping table of the endpoint phone numbers and just map the messages to the corresponding phone number.
Example:
Conversation 1 = UserA(1-234-567-8910) => UserA(1-234-567-8911)
Conversation 2 = UserC(1-234-567-8912) => UserD(1-234-567-8913)
If UserA sends a message, it will be forwarded to UserB, and vice-versa. Same goes for Conversation 2.
On the server side:
Upon the initial connection, the server would map that UserA wants to talk to UserB. This would remain in the lookup table until UserA stops wanting to communicate with UserB.
This would require that each user could only have one conversation going at a time, which may not fit for the purposes of the initial poster, but I hope that it will help someone.
Upvotes: 0
Reputation: 73027
Twilio developer evangelist here.
SMS does not have threading baked in, so this is not possible with just one phone number. You can prove this to yourself by opening the SMS app on your phone and trying to respond to the second to last message you received from someone.
You have two options:
You insist that your users include a specific ID within messages in a thread so that you can parse the message and extract the ID to tie the threads together.
You conduct separate conversations between the same users using different Twilio numbers. This way you can tie the thread together using the number that was used.
Let me know if that helps at all.
Upvotes: 2