DCtheTall / twilly

A library which provides an abstract syntax for designing Twilio SMS interactions. Designed for use with Node.js and Express
MIT License
52 stars 3 forks source link

cookie expiration prevents onInteractionEnd from firing #1

Open DCtheTall opened 5 years ago

DCtheTall commented 5 years ago

Twilio's documentation on SMS cookies states

The cookie will expire after 4 hours. So if an incoming call or SMS message arrives 4 hours after the cookie was set, then the expired cookie will not be included with the request.

Right now, if a cookie expires this way, onInteractionEnd will never fire which means if you try to set up hooks to keep records of the interaction.

I think the current Flow context is a little clunky and think it'd be simpler/a better user experience to have context by user defined and retrieved from a user-defined hook.

I should probably add a hook a message is sent, since onMessage lets you see what the cookie was on Twilio in an incoming message, it makes sense to also have a hook when the outbound is sent as well to see what the new state of the cookie is.

If anyone wants to implement this PRs are welcome, otherwise I can get to it.