Webhooks to Email Message

503 views
Skip to first unread message

Dave Banks

unread,
May 16, 2012, 9:59:13 AM5/16/12
to mandrill-a...@googlegroups.com
Having looked at the API I have enabled a web hook to run when an email is opened. This is successfully being POSTed a status, timestamp and some form of message ID. I can't work out how to link this ID back to a message so that I know what was opened.

When you send a message through Mandrill you don't get given an ID just an initial status.

Any pointers would be great :)

-Dave

Loren Norman

unread,
May 16, 2012, 11:46:15 AM5/16/12
to mandrill-a...@googlegroups.com
Hey Dave,

Couple things. We had a small bug with our webhooks that got fixed this morning, I assume you were seeing the responses before that and if you test a webhook now, the payload will have changed.

Second, the way Mandrill works. We do not store your message on our side in any kind of long-term persistent way, so the approach of looking for an ID and tying it back to some resource on our end is not viable for you. We only store your messages temporarily as a way to make your recent history searchable, which helps you get an idea of how you're doing, troubleshoot issues, etc but you can't retrieve the full email.

What you will find in the webhook payload, however, is all the data about the message itself. You can use this to look it up on your end and connect the dots. Mostly it depends on what you're trying to build here.

Let us know if you have further questions!

Dave Banks

unread,
May 16, 2012, 12:08:06 PM5/16/12
to mandrill-a...@googlegroups.com
Hey Loren,

Thanks for the reply. I have just tested again with the same result.

I will now try to put it into context. I am trying to send a confirm your email address email. And would like to monitor when this has been opened. So I send it out with mandril using the API. The response I get from that is the email address sent to and an initial status (queued/sent etc...).

Then I get a webhook response saying it has been sent with the following:
[ { "event": "send", "msg": { "clicks": [], "email": "em...@example.com", "opens": [], "state": "sent", "subject": "My Subject Line", "tags": [ 77849, 77853 ], "ts": 1337183244 }, "ts": 1337183244 } ]

From this I can indeed look up the email on our system based on subject line and email address etc.... However when I get the 'open' webhook response I only get the following:
[ { "event": "open", "msg": "eae79bf55b604cfba0881f4f4bd9e832", "ts": 1337183265 } ]

Just the event type (open) a timestamp and a msg element. I assume this is a unique ID of the message which would be great if I could get an ID for a message from anywhere else, like when I initially send it. But this is the first time that I get it and therefore can't see how to link that back to a message in our system. I can't find a way to get this msg id from anywhere else.

I may well be missing something obvious :) Its not a major problem but would be nice to be able to keep track of opens. I am loving the templating system and am looking forward to testing the system with real users.

Loren Norman

unread,
May 16, 2012, 12:15:01 PM5/16/12
to mandrill-a...@googlegroups.com
Oh that is interesting. I am thinking that "open" payload is probably wrong, I would have expected it to look like the "send" payload. I'm double-checking that for you now.

Loren Norman

unread,
May 16, 2012, 12:44:49 PM5/16/12
to mandrill-a...@googlegroups.com
Ok, couple things.

Yes, that "open" payload is wrong, it will look like the "send" payload once we get it fixed.

A note about opens: a lot of them won't be tracked, they only work for HTML emails that have images turned on. We will also automatically count a click as an open, as well. So, depending on why you care about opens (as opposed to actual clicks, which should end up as events on your server anyway), you may want to re-evaluate how much you trust them.

One other thing I wanted to note about closing the loop on emails: metadata. You can append metadata to any of your email messages at send time, and that metadata will be reflected in the webhook payload. So feel free to slap an ID of your choosing in there when you send an email, and then look for it in the webhook to close the loop. You could use this for all kinds of things far beyond the scope of your confirmation emails. Just a thought!

I'll let you know when we get another fix out for the webhooks. Thanks Dave

On Wednesday, May 16, 2012 12:08:06 PM UTC-4, Dave Banks wrote:

Dave Banks

unread,
May 16, 2012, 12:49:46 PM5/16/12
to mandrill-a...@googlegroups.com
Brilliant,

Thanks for the info about metadata. That is very useful and I will be sure to use them.

Loren Norman

unread,
May 16, 2012, 2:47:45 PM5/16/12
to mandrill-a...@googlegroups.com
OK the other webhooks should be fixed now, take a swing at it!

Dave Banks

unread,
May 17, 2012, 9:31:01 AM5/17/12
to mandrill-a...@googlegroups.com
Great it looks like you fixed it :)

Many Thanks
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages