ithunt / asksg

RIT Ask SG
4 stars 1 forks source link

Twilio does not support conversations #46

Closed rpk7524 closed 11 years ago

rpk7524 commented 11 years ago

Twilio needs to check if an incoming message should be assigned to an existing conversation.

Reproduction steps: User sends message to ASKSG twilio phone #. Conversation is created, with message. Senator replies to message. New message is attached to existing conversation. User replies back. Error: New conversation is created, with message. Expected: Incoming message is attached to existing conversation.

dge9788 commented 11 years ago

Twilio supports HTTP cookies for conversation tracking. See https://www.twilio.com/docs/api/twiml/sms/your_response

dge9788 commented 11 years ago

I'm not sure if it's possible to set the outbound cookie when I create an SMS to reply to a message. Will investigate.

dge9788 commented 11 years ago

The cookie method is not sufficient. We might need to make all messages from a given recipient go into one Conversation.

rpk7524 commented 11 years ago

Write a specification that works off of the author and time (two separate specifications, then and them together). See some sample code in find conversations, but it needs to be refactored into multiple specs. I think a month or two from the last reply is probably sufficient to make a new conversation. Be aware that you need to use author, not get recipient for the spec. Also, findOne, not findAll. If you ensure that twilio always sets conversations modified on handle new message and reply, you can use that instead of the last messages created (easier spec to write).

dge9788 commented 11 years ago

Now works. Does not find by date as suggested above though -- texts are added to the existing conversation always.

dge9788 commented 11 years ago

Sponsor would like it to be a week instead of a month. Need to 'and' specifications together

dge9788 commented 11 years ago

I understand how to and the predicates together (using the example in ConversationServiceImpl.java), but I don't understand how to express the condition "if creation time is more recent than a week ago". i assume i need to use criteriaBuilder.gt for this

rpk7524 commented 11 years ago

Would modifying the CreatedSinceSpecification to create a new specification that worked off of the modified date property work?