Skip to content

Commit

Permalink
Add message tracking feature for draft sending
Browse files Browse the repository at this point in the history
  • Loading branch information
pfista committed May 17, 2017
1 parent d92140b commit d7a42dd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,26 @@ draft.delete()
# client.drafts.delete(draft.id, {'version': draft.version})
```

### Message Tracking Features

If you have webhooks enabled for your developer application you can now access Nylas' [Message Tracking Features](https://www.nylas.com/docs/platform#enabling_tracking) to see when a recipient opens, replies, or clicks links within a message.

```python
# Send a message with tracking enabled
draft = client.drafts.create()
draft.to = [{'name': 'Python SDK open tracking test', 'email': 'inboxapptest415@gmail.com'}]
draft.subject = "Python SDK open tracking test"
draft.body = "Stay polish, stay hungary"
draft.tracking = { 'links': 'false', 'opens': 'true', 'thread_replies': 'true', 'payload':'python sdk open tracking test' }
draft.send()
```

It’s important to note that you must wrap links in `<a>` tags for them to be
tracked. Most email clients automatically “linkify” things that look like links,
like `10.0.0.1`, `tel:5402502334`, or `apple.com`. For links to be tracked
properly, you must linkify the content before sending the draft.


### Working with Events

The following example shows how to create and update an event.
Expand Down
2 changes: 1 addition & 1 deletion nylas/client/restful_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ class Draft(Message):
attrs = ["bcc", "cc", "body", "date", "files", "from", "id",
"account_id", "object", "subject", "thread_id", "to",
"unread", "version", "file_ids", "reply_to_message_id",
"reply_to", "starred", "snippet"]
"reply_to", "starred", "snippet", "tracking"]
collection_name = 'drafts'

def __init__(self, api, thread_id=None):
Expand Down
9 changes: 9 additions & 0 deletions tests/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@
ev.calendar_id = calendar.id
ev.save(notify_participants='true')

# Send a message with tracking enabled
print 'Send a message with open tracking enabled'
draft = client.drafts.create()
draft.to = [{'name': 'Python SDK open tracking test', 'email': 'inboxapptest415@gmail.com'}]
draft.subject = "Python SDK open tracking test"
draft.body = "Stay polish, stay hungary"
draft.tracking = { 'links': 'false', 'opens': 'true', 'thread_replies': 'true', 'payload':'python sdk open tracking test' }
draft.send()

print 'Listing folders'
for label in client.labels:
print label.display_name

0 comments on commit d7a42dd

Please sign in to comment.