We recently revised how we do notifications. A mayor part of the update is allowing people to reply directly to a notification by email.
Any module in P2PU can send a notification to a user. If the module supports receiving a reply to the notification, it passes a callback URL to the notification module when it sends a notification.
notify(user, ‘subject’, ‘notification text’, ‘/comments/4/reply’)
The callback URL get saved together with a response token that is then attached to the email address the notification is sent from.
We make use of Sendgrid for sending and receiving email. Sendgrid provides a API called parse that handles receiving email. The parse API calls a specific URL on P2PU whenever a reply is received.
The reply then gets handled by the notification module where the token is verified and the user sending the reply is determined.
The notification module then uses the callback URL to let the original module know that a user responded and passes along the user and the reply text.
POST /comments/4/reply user=’Bob’, text=’The reply text comes here’