Skip to content

Commit d422eee

Browse files
authored
feat(messages): add support for tracking_options, raw_mime fields and new MessageFields enum values (#645)
* Added support for new message `fields` query parameter values: `include_tracking_options` and `raw_mime` * Added support for `rawMime` property in Message responses when using `fields=raw_mime` * feat: add message cleaning and scheduled messages examples * Ran prettier * Clean up
1 parent 6801ebd commit d422eee

File tree

10 files changed

+858
-4
lines changed

10 files changed

+858
-4
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
10+
### Added
11+
- Support for new message `fields` query parameter values: `include_tracking_options` and `raw_mime`
12+
- Support for `trackingOptions` property in Message responses when using `fields=include_tracking_options`
13+
- Support for `rawMime` property in Message responses when using `fields=raw_mime`
14+
- `MessageTrackingOptions` interface for tracking message opens, thread replies, link clicks, and custom labels
15+
816
## [7.10.0] - 2025-05-27
917

1018
### Added

examples/.env.example

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ MEETING_LINK=your_meeting_link_here
1111
NYLAS_GRANT_ID=your_grant_id_here
1212

1313
# Calendar ID (required for event creation/updates)
14-
NYLAS_CALENDAR_ID=your_calendar_id_here
14+
NYLAS_CALENDAR_ID=your_calendar_id_here
15+
16+
# For testing message sending (optional)
17+
TEST_EMAIL=your-test-email@example.com

examples/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This directory contains examples of how to use the Nylas Node.js SDK to interact
55
## Examples
66

77
- [Notetakers](./notetakers/README.md) - Examples of how to use the Nylas Notetakers API to invite a Notetaker bot to meetings, get recordings and transcripts, and more.
8+
- [Messages](./messages/README.md) - Examples of how to use the Nylas Messages API to list, find, send, update messages, and work with new features like tracking options and raw MIME data.
89

910
## Running the Examples
1011

@@ -31,10 +32,19 @@ To run these examples, you'll need to:
3132
```bash
3233
# Using ts-node
3334
npx ts-node notetakers/notetaker.ts
35+
npx ts-node calendars/event_with_notetaker.ts
36+
npx ts-node messages/messages.ts
37+
38+
# Or using npm scripts
39+
npm run notetakers
40+
npm run calendars
41+
npm run messages
3442

3543
# Or if you compiled the examples
3644
npm run build
3745
node dist/notetakers/notetaker.js
46+
node dist/calendars/event_with_notetaker.js
47+
node dist/messages/messages.js
3848
```
3949

4050
## Documentation

examples/messages/ENVIRONMENT.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Environment Setup for Messages Example
2+
3+
## Required Environment Variables
4+
5+
Create a `.env` file in the `examples` directory with the following variables:
6+
7+
```bash
8+
# Required
9+
NYLAS_API_KEY=your_api_key_here
10+
NYLAS_GRANT_ID=your_grant_id_here
11+
12+
# Optional
13+
NYLAS_API_URI=https://api.us.nylas.com
14+
15+
# For testing message sending (optional)
16+
TEST_EMAIL=your-test-email@example.com
17+
```
18+
19+
## Getting Your API Key and Grant ID
20+
21+
1. **API Key**: Get your API key from the [Nylas Dashboard](https://dashboard.nylas.com)
22+
2. **Grant ID**: After connecting an email account, you'll get a grant ID that represents that connection
23+
24+
## Testing Message Sending
25+
26+
If you want to test the message sending functionality, set the `TEST_EMAIL` environment variable to an email address you control. The example will skip message sending if this variable is not set.
27+
28+
## Running the Example
29+
30+
Once your environment variables are set:
31+
32+
```bash
33+
cd examples
34+
npm install
35+
npm run messages
36+
```
37+
38+
## What the Example Demonstrates
39+
40+
- **Message Fields**: Different ways to query messages with various field options
41+
- **Tracking Options**: How tracking data appears in message responses
42+
- **Raw MIME**: Getting raw MIME data for messages
43+
- **Message Operations**: Listing, finding, updating, and sending messages
44+
- **Scheduled Messages**: Working with scheduled message functionality
45+
- **Message Cleaning**: Using the clean messages API

examples/messages/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Messages Examples
2+
3+
This directory contains examples of how to use the Nylas Messages API to list, find, send, and work with messages.
4+
5+
## Features Demonstrated
6+
7+
This example demonstrates:
8+
9+
- **Message Operations**: List, find, send, update, and delete messages
10+
- **Message Fields**: Using different `fields` query parameters to get different data:
11+
- `standard` - Standard message payload
12+
- `include_headers` - Message with custom headers
13+
- `include_tracking_options` - Message with tracking settings
14+
- `raw_mime` - Raw MIME data (Base64url-encoded)
15+
- **Message Tracking**: Working with tracking options for opens, thread replies, and link clicks
16+
- **Scheduled Messages**: Creating, listing, and managing scheduled messages
17+
- **Message Cleaning**: Using the clean messages API to process message content
18+
- **Error Handling**: Proper error handling with NylasApiError
19+
20+
## Prerequisites
21+
22+
Before running this example, make sure you have:
23+
24+
1. A Nylas application with an API key
25+
2. A connected email account (grant)
26+
3. The required environment variables set up
27+
28+
## Environment Variables
29+
30+
Create a `.env` file in the parent `examples` directory with:
31+
32+
```bash
33+
# Required
34+
NYLAS_API_KEY=your_api_key_here
35+
NYLAS_GRANT_ID=your_grant_id_here
36+
37+
# Optional
38+
NYLAS_API_URI=https://api.us.nylas.com
39+
```
40+
41+
## Running the Example
42+
43+
```bash
44+
cd examples
45+
npm install
46+
npx ts-node messages/messages.ts
47+
```
48+
49+
## Example Output
50+
51+
The example will demonstrate:
52+
1. Listing messages with different field options
53+
2. Finding specific messages with tracking data
54+
3. Sending messages with tracking enabled
55+
4. Working with raw MIME data
56+
5. Managing scheduled messages
57+
6. Cleaning message content
58+
59+
Each operation includes detailed console output showing the API responses and data structures.

0 commit comments

Comments
 (0)