Skip to content

Commit 27ebf6b

Browse files
authored
feat: Add Notetaker API support (#519)
* feat: Added support for Notetaker APIs * feat: Added support for Notetaker via the calendar and event APIs Added examples and fixed some of the notetaker paths fix errors Fixed examples fix failing actions fixed coverage issues PR feedback pr feedback comments * fix issues with linting
1 parent 08afb02 commit 27ebf6b

File tree

17 files changed

+956
-6
lines changed

17 files changed

+956
-6
lines changed

.github/workflows/sdk-reference.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
with:
2323
ruby-version: 3.0
2424
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
25-
- name: Run rubocop
25+
- name: Generate documentation
2626
run: bundle exec yard
2727
- name: Set env BRANCH
2828
run: echo "BRANCH=$(echo $GITHUB_REF | cut -d'/' -f 3)" >> $GITHUB_ENV

.rubocop.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
inherit_from: .rubocop_todo.yml
22

3-
require: rubocop-rspec
3+
require:
4+
- rubocop-rspec
5+
- rubocop-capybara
6+
47
AllCops:
58
TargetRubyVersion: 3.0
69
DisplayCopNames: true

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
### Unreleased
4+
* Added support for Notetaker APIs
5+
* Added support for Notetaker via the calendar and event APIs
6+
37
### 6.3.0 / 2025-03-03
48
* Removed `file_path` from `File` object to match the Send API schema
59
* Added events import function to the RubySDK
@@ -53,7 +57,7 @@
5357
* **BREAKING CHANGE**: Officially support minimum Ruby v3
5458
* **BREAKING CHANGE**: Removed all models and typing from the SDK
5559
* **REMOVED**: Local Webhook development support is removed due to incompatibility
56-
* Rewrote the majority of SDK to be more modular and efficient
60+
* Rewritten the majority of SDK to be more modular and efficient
5761
* Created error classes for the different API errors as well as SDK-specific errors
5862
* Added a configurable timeout for outgoing calls to the API
5963

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
source "https://rubygems.org"
44

55
gemspec name: "nylas"
6+
7+
gem "rake", "~> 13.2", group: :development

examples/README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Nylas Ruby SDK Examples
2+
3+
This directory contains example applications and scripts that demonstrate how to use the Nylas Ruby SDK.
4+
5+
## Directory Structure
6+
7+
```
8+
examples/
9+
├── README.md # This file
10+
├── events/ # Event-related examples
11+
│ └── event_notetaker_example.rb # Example of creating events with Notetaker
12+
└── notetaker/ # Standalone Notetaker examples
13+
├── README.md # Notetaker-specific documentation
14+
└── notetaker_example.rb # Basic Notetaker functionality example
15+
```
16+
17+
## Running the Examples
18+
19+
Before running any example, make sure to:
20+
21+
1. Install the required dependencies:
22+
```bash
23+
bundle install
24+
```
25+
26+
2. Set up your environment variables:
27+
```bash
28+
export NYLAS_API_KEY="your_api_key"
29+
export NYLAS_API_URI="https://api.us.nylas.com" # Optional, defaults to this value
30+
```
31+
32+
3. Some examples may require additional environment variables. Check the specific example's documentation or code for details.
33+
34+
## Available Examples
35+
36+
### Events
37+
- `events/event_notetaker_example.rb`: Demonstrates how to create calendar events with Notetaker integration, including:
38+
- Creating an event with a Notetaker bot
39+
- Retrieving Notetaker details
40+
- Updating event and Notetaker settings
41+
42+
### Notetaker
43+
- `notetaker/notetaker_example.rb`: Shows basic Notetaker functionality, including:
44+
- Inviting a Notetaker to a meeting
45+
- Listing all Notetakers
46+
- Getting media from a Notetaker (recordings and transcripts)
47+
- Leaving a Notetaker session
48+
49+
Prerequisites:
50+
- Ruby 3.0 or later
51+
- A Nylas API key
52+
- A meeting URL (Zoom, Google Meet, or Microsoft Teams)
53+
54+
Additional environment variables needed:
55+
```bash
56+
export MEETING_LINK="your_meeting_link_here"
57+
```
58+
59+
## Contributing
60+
61+
When adding new examples:
62+
63+
1. Create them in the appropriate subdirectory based on functionality
64+
2. Include clear documentation and comments in the code
65+
3. List any required environment variables at the top of the file
66+
4. Update this README.md with information about the new example
67+
68+
## Support
69+
70+
If you encounter any issues or have questions about these examples, please:
71+
1. Check the [Nylas documentation](https://developer.nylas.com)
72+
2. Visit our [GitHub repository](https://github.com/nylas/nylas-ruby)
73+
3. Contact [Nylas support](https://support.nylas.com)
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
$LOAD_PATH.unshift File.expand_path('../../lib', __dir__)
5+
require "nylas"
6+
require "json"
7+
require "time"
8+
9+
# Initialize the Nylas client
10+
nylas = Nylas::Client.new(
11+
api_key: ENV["NYLAS_API_KEY"],
12+
api_uri: ENV["NYLAS_API_URI"] || "https://api.us.nylas.com"
13+
)
14+
15+
def create_event_with_notetaker(nylas)
16+
puts "\n=== Creating Event with Notetaker ==="
17+
18+
# Create the event time
19+
start_time = Time.now + (24 * 60 * 60) # tomorrow
20+
end_time = start_time + (60 * 60) # 1 hour later
21+
22+
request_body = {
23+
title: "Project Planning Meeting",
24+
description: "Initial project planning and resource allocation",
25+
when: {
26+
start_time: start_time.to_i,
27+
end_time: end_time.to_i
28+
},
29+
metadata: {
30+
project_id: "PROJ-123",
31+
priority: "high"
32+
},
33+
conferencing: {
34+
provider: "Google Meet",
35+
autocreate: {}
36+
},
37+
notetaker: {
38+
name: "Nylas Notetaker",
39+
meeting_settings: {
40+
video_recording: true,
41+
audio_recording: true,
42+
transcription: true
43+
}
44+
}
45+
}
46+
47+
query_params = {
48+
calendar_id: ENV["NYLAS_CALENDAR_ID"]
49+
}
50+
51+
puts "Creating event with request body: #{JSON.pretty_generate(request_body)}"
52+
53+
event, request_id = nylas.events.create(
54+
identifier: ENV["NYLAS_GRANT_ID"],
55+
request_body: request_body,
56+
query_params: query_params
57+
)
58+
59+
puts "Created event with ID: #{event[:id]}"
60+
puts "Event Notetaker ID: #{event[:notetaker][:id]}"
61+
puts "Request ID: #{request_id}"
62+
63+
event
64+
end
65+
66+
def get_event_notetaker(nylas, event_id)
67+
puts "\n=== Retrieving Event Notetaker ==="
68+
69+
# First get the event to get the Notetaker ID
70+
begin
71+
event, request_id = nylas.events.find(
72+
identifier: ENV["NYLAS_GRANT_ID"],
73+
event_id: event_id,
74+
query_params: { calendar_id: ENV["NYLAS_CALENDAR_ID"] }
75+
)
76+
rescue StandardError => e
77+
puts "Error getting event: #{e.message}"
78+
return nil
79+
end
80+
81+
unless event[:notetaker] && event[:notetaker][:id]
82+
puts "No Notetaker found for event #{event_id}"
83+
return nil
84+
end
85+
86+
notetaker, request_id = nylas.notetakers.find(
87+
notetaker_id: event[:notetaker][:id],
88+
identifier: ENV["NYLAS_GRANT_ID"]
89+
)
90+
91+
puts "Found Notetaker for event #{event_id}:"
92+
puts "- ID: #{notetaker[:id]}"
93+
puts "- State: #{notetaker[:state]}"
94+
puts "- Meeting Provider: #{notetaker[:meeting_provider]}"
95+
puts "- Meeting Settings:"
96+
puts " - Video Recording: #{notetaker[:meeting_settings][:video_recording]}"
97+
puts " - Audio Recording: #{notetaker[:meeting_settings][:audio_recording]}"
98+
puts " - Transcription: #{notetaker[:meeting_settings][:transcription]}"
99+
puts "Request ID: #{request_id}"
100+
101+
notetaker
102+
end
103+
104+
def update_event_and_notetaker(nylas, event_id, notetaker_id)
105+
puts "\n=== Updating Event and Notetaker ==="
106+
107+
request_body = {
108+
title: "Updated Project Planning Meeting",
109+
description: "Revised project planning with new timeline",
110+
metadata: {
111+
project_id: "PROJ-123",
112+
priority: "urgent"
113+
},
114+
notetaker: {
115+
id: notetaker_id,
116+
name: "Updated Nylas Notetaker",
117+
meeting_settings: {
118+
video_recording: false,
119+
audio_recording: true,
120+
transcription: false
121+
}
122+
}
123+
}
124+
125+
query_params = {
126+
calendar_id: ENV["NYLAS_CALENDAR_ID"]
127+
}
128+
129+
updated_event, request_id = nylas.events.update(
130+
identifier: ENV["NYLAS_GRANT_ID"],
131+
event_id: event_id,
132+
request_body: request_body,
133+
query_params: query_params
134+
)
135+
136+
puts "Updated event with ID: #{updated_event[:id]}"
137+
puts "Request ID: #{request_id}"
138+
139+
updated_event
140+
end
141+
142+
def main
143+
# Check for required environment variables
144+
required_env_vars = %w[NYLAS_API_KEY NYLAS_GRANT_ID NYLAS_CALENDAR_ID]
145+
missing_vars = required_env_vars.select { |var| ENV[var].nil? }
146+
147+
unless missing_vars.empty?
148+
raise "Missing required environment variables: #{missing_vars.join(', ')}"
149+
end
150+
151+
puts "Using API key: #{ENV['NYLAS_API_KEY'][0..4]}..."
152+
153+
# Initialize Nylas client
154+
nylas = Nylas::Client.new(
155+
api_key: ENV["NYLAS_API_KEY"],
156+
api_uri: ENV["NYLAS_API_URI"] || "https://api.us.nylas.com"
157+
)
158+
159+
begin
160+
# Create an event with a Notetaker
161+
event = create_event_with_notetaker(nylas)
162+
unless event
163+
puts "Failed to create event"
164+
return
165+
end
166+
167+
# Get the Notetaker for the event
168+
notetaker = get_event_notetaker(nylas, event[:id])
169+
unless notetaker
170+
puts "Failed to get Notetaker for event #{event[:id]}"
171+
return
172+
end
173+
174+
# Update both the event and its Notetaker
175+
updated_event = update_event_and_notetaker(nylas, event[:id], notetaker[:id])
176+
unless updated_event
177+
puts "Failed to update event #{event[:id]}"
178+
return
179+
end
180+
181+
rescue StandardError => e
182+
puts "An error occurred: #{e.message}"
183+
end
184+
end
185+
186+
main if __FILE__ == $PROGRAM_NAME

0 commit comments

Comments
 (0)