Skip to content

Commit d7a42dd

Browse files
committed
Add message tracking feature for draft sending
1 parent d92140b commit d7a42dd

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,26 @@ draft.delete()
270270
# client.drafts.delete(draft.id, {'version': draft.version})
271271
```
272272

273+
### Message Tracking Features
274+
275+
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.
276+
277+
```python
278+
# Send a message with tracking enabled
279+
draft = client.drafts.create()
280+
draft.to = [{'name': 'Python SDK open tracking test', 'email': '[email protected]'}]
281+
draft.subject = "Python SDK open tracking test"
282+
draft.body = "Stay polish, stay hungary"
283+
draft.tracking = { 'links': 'false', 'opens': 'true', 'thread_replies': 'true', 'payload':'python sdk open tracking test' }
284+
draft.send()
285+
```
286+
287+
It’s important to note that you must wrap links in `<a>` tags for them to be
288+
tracked. Most email clients automatically “linkify” things that look like links,
289+
like `10.0.0.1`, `tel:5402502334`, or `apple.com`. For links to be tracked
290+
properly, you must linkify the content before sending the draft.
291+
292+
273293
### Working with Events
274294

275295
The following example shows how to create and update an event.

nylas/client/restful_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ class Draft(Message):
307307
attrs = ["bcc", "cc", "body", "date", "files", "from", "id",
308308
"account_id", "object", "subject", "thread_id", "to",
309309
"unread", "version", "file_ids", "reply_to_message_id",
310-
"reply_to", "starred", "snippet"]
310+
"reply_to", "starred", "snippet", "tracking"]
311311
collection_name = 'drafts'
312312

313313
def __init__(self, api, thread_id=None):

tests/system.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@
5555
ev.calendar_id = calendar.id
5656
ev.save(notify_participants='true')
5757

58+
# Send a message with tracking enabled
59+
print 'Send a message with open tracking enabled'
60+
draft = client.drafts.create()
61+
draft.to = [{'name': 'Python SDK open tracking test', 'email': '[email protected]'}]
62+
draft.subject = "Python SDK open tracking test"
63+
draft.body = "Stay polish, stay hungary"
64+
draft.tracking = { 'links': 'false', 'opens': 'true', 'thread_replies': 'true', 'payload':'python sdk open tracking test' }
65+
draft.send()
66+
5867
print 'Listing folders'
5968
for label in client.labels:
6069
print label.display_name

0 commit comments

Comments
 (0)