ACDC wrote:Jaymer wrote:
The concept that I have in my mind right now is:
2. Receive the event call back via the Node.js as you suggested, or first prize for me, receive the Mandrill call back directly into AIM
RE: receive the Mandrill Webhook directly into AIM
TL;DR This isn't even possible now
ok, do this simple thing.
copy this code below to clipboard.
Code: Select all
[{"event":"open","ts":1536132312,"user_agent":"Mozilla\\/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/68.0.3440.84 Safari\\/537.36","user_agent_parsed":{"type":"Browser","ua_family":"Chrome","ua_name":"Chrome 68.0.3440.84","ua_version":"68.0.3440.84", "ua_url":"http:\\/\\/www.google.com\\/chrome","ua_company":"Google Inc.","ua_company_url":"http:\\/\\/www.google.com\\/","ua_icon":"http:\\/\\/cdn.mandrill.com\\/img\\/email-client-icons\\/chrome.png","os_family":"OS X","os_name":"OS X","os_url":"http:\\/\\/www.apple.com\\/osx\\/","os_company":"Apple Computer, Inc.","os_company_url":"http:\\/\\/www.apple.com\\/","os_icon":"http:\\/\\/cdn.mandrill.com\\/img\\/email-client-icons\\/macosx.png","mobile":false},"ip":"70.126.141.227","location":{"country_short":"US","country":"United States","region":"Florida","city":"Tampa","latitude":27.9475193024,"longitude":-82.4584274292,"postal_code":"33601","timezone":"-04:00"},"_id":"443082dac81649978b07f944d251c451","msg":{"ts":1536132236,"_id":"443082dac81649978b07f944d251c451","state":"sent","subject":"My Office Blast 3:18am 275 ppl","email":"[email protected]","tags":["MyCustomTag"],"opens":[{"ts":1536132312,"ip":"70.126.141.227","location":"Florida, US","ua":"OS X\\/OS X\\/Chrome\\/Chrome 68.0.3440.84"}],"clicks":[],"smtp_events":[{"ts":1536132273,"type":"sent","diag":"250 Requested mail action okay, completed: id=0MKsCM-1fxSAz1nwu-0000FE","source_ip":"198.2.180.28","destination_ip":"74.208.5.21","size":2797}],"subaccount":"demo","resends":[],"_version":"DgI4TT6W9EDqtvovn3A3IA","metadata":[{"email_id":"834418"}],"sender":"[email protected]","template":null}}]
go here:
https://codebeautify.org/jsonviewer
paste code into left box
click Beautify button in center panel
The "prettied" code shows up on the right.
Thats a real view of the JSON structure Aware would have to parse.
Based on what I've seen getting JSON back from REST replies, it would make sense that IF Vlad offered some way to parse a reply, he'd follow the same routine observed in REST replies, which means:
You'd have to create a BO structure in Aware to accommodate this data.
1) BO "TheEvent" (top level name doesn't matter). Fields like event, ts, ip (and others at that 2nd level)
2) The data in location has to go in another BO. A field in BO_TheEvent is named "location" and is an OS (owned single) of BO_location. All those fields "under" location are now fields in BO_location.
Similarly, any other 2nd level field that is an array of other values becomes another BO. BO_user_agent_parsed and BO_msg
(bear with me, i know this is complicated.)
3) all this repeats with BO_msg. Its top-level fields are: state, subject, email, but BOs must be created to hold the child arrays: tags, opens, clicks, etc.
NOTE: If you do NOT want or need any data from user_agent_parsed, for example, (step 2 above), then Aware gracefully doesn't complain and will ignore that entire element path if you don't have that field defined in BO_TheEvent. So its easy to pick & choose which data you want to preserve, BUT even for just 1 field, you have to create the BO (example. If you only needed Location.timezone, you'd still need BO_location and it would have only 1 field in it).
So now you end up having a BO structure that looks very similar to the Beautify layout:
BO_TheEvent (fields event, ts, user_agent, ip)
L__ BO_user_agent_parsed (fields type, ua_family, ua_name)
L__ BO_location (fields country, region, state)
L__ BO_msg (fields ts, state, subject)
...L___ BO_opens
...L___ BO_smtp_events
...L___ BO_meta-data
......L___ BO_email_id
*
Once an Event would be Parsed/Received/???, and
IF it follows the same JSON REST Reply routine, then it would create rows and populate all these fields automatically. One BO_TheEvent structure for each Webhook sent by whomever.
All of this structure is in place just to handle 1 Webhook, BUT remember they are also individual AWARE BOs. So, I would add a field in BO_email_id for ProcessedYN, or Date_Processed (these will be undefined or a RULE can set them). Then have a Scheduled Event scan the BO_email_id table for any un-Processed records. Finding the OutgoingEmail record for that ID now links you to all existing Aware data. You can now post opened/clicked or tracking data anywhere you want. You can traverse all the way back up to TheEvent to get the type ( BO_email_id.ob_BO_meta_data.ob_BO_msg.ob_BO_TheEvent.event ).
(
* NOTE: I have a problem with this description above. From Beautify, note the difference between
locations and
opens.
opens allows for multiple arrays. Its is an Object of Arrays. Locations has only 1 array.
The names of these elements come from a API Spec. Aware matches up the element name with a real field (attribute) in the BO.
Well, we come to a problem if we are trying to design a Structure to handle Mandrill Webhooks. Because
meta-data is just like
opens, except the NAME of the element varies - its not in a "spec" anywhere. It just means that if you add another piece of metadata, you have to add another BO just to receive the data for that 1 field. OK, I digress, this may not be a big deal, cause you'd have to go back into code anyway to handle that data anyway. )