Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
nylas-python Changelog
======================

Unreleased
----------------
* Added support for Notetaker APIs
* Added support for Notetaker via the calendar and event APIs

v6.8.0
----------------
* Added support for `list_import_events`
Expand Down
52 changes: 52 additions & 0 deletions examples/notetaker_api_demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Notetaker API Demo

This demo showcases how to use the Nylas Notetaker API to create, manage, and interact with notes.

## Features Demonstrated

- Creating new notes
- Retrieving notes
- Updating notes
- Deleting notes
- Managing note metadata
- Sharing notes with other users

## Prerequisites

- Python 3.8+
- Nylas Python SDK (local version from this repository)
- Nylas API credentials (Client ID and Client Secret)

## Setup

1. Install the SDK in development mode:
```bash
# From the root of the nylas-python repository
pip install -e .
```

2. Set up your environment variables:
```bash
export NYLAS_API_KEY='your_api_key'
export NYLAS_API_URI='https://api.nylas.com' # Optional, defaults to https://api.nylas.com
```

## Running the Demo

From the root of the repository:
```bash
python examples/notetaker_api_demo/notetaker_demo.py
```

## Code Examples

The demo includes examples of:

1. Creating a new note
2. Retrieving a list of notes
3. Updating an existing note
4. Deleting a note
5. Managing note metadata
6. Sharing notes with other users

Each example is documented with comments explaining the functionality and expected output.
145 changes: 145 additions & 0 deletions examples/notetaker_api_demo/notetaker_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
import os
import sys
import json
from nylas import Client
from nylas.models.notetakers import NotetakerMeetingSettingsRequest, NotetakerState, InviteNotetakerRequest
from nylas.models.errors import NylasApiError

# Initialize the Nylas client
nylas = Client(
api_key=os.getenv("NYLAS_API_KEY"),
api_uri=os.getenv("NYLAS_API_URI", "https://api.us.nylas.com")
)

def invite_notetaker():
"""Demonstrates how to invite a Notetaker to a meeting."""
print("\n=== Inviting Notetaker to Meeting ===")

try:
meeting_link = os.getenv("MEETING_LINK")
if not meeting_link:
raise ValueError("MEETING_LINK environment variable is not set. Please set it with your meeting URL.")

request_body: InviteNotetakerRequest = {
"meeting_link": meeting_link,
"name": "Nylas Notetaker",
"meeting_settings": {
"video_recording": True,
"audio_recording": True,
"transcription": True
}
}

print(f"Request body: {json.dumps(request_body, indent=2)}")

notetaker = nylas.notetakers.invite(request_body=request_body)

print(f"Invited Notetaker with ID: {notetaker.data.id}")
print(f"Name: {notetaker.data.name}")
print(f"State: {notetaker.data.state}")
return notetaker
except NylasApiError as e:
print(f"Error inviting notetaker: {str(e)}")
print(f"Error details: {e.__dict__}")
raise
except json.JSONDecodeError as e:
print(f"JSON decode error: {str(e)}")
raise
except Exception as e:
print(f"Unexpected error in invite_notetaker: {str(e)}")
print(f"Error type: {type(e)}")
print(f"Error details: {e.__dict__}")
raise

def list_notetakers():
"""Demonstrates how to list all Notetakers."""
print("\n=== Listing All Notetakers ===")

try:
notetakers = nylas.notetakers.list()

print(f"Found {len(notetakers.data)} notetakers:")
for notetaker in notetakers.data:
print(f"- {notetaker.name} (ID: {notetaker.id}, State: {notetaker.state})")

return notetakers
except NylasApiError as e:
print(f"Error listing notetakers: {str(e)}")
raise
except Exception as e:
print(f"Unexpected error in list_notetakers: {str(e)}")
raise

def get_notetaker_media(notetaker_id):
"""Demonstrates how to get media from a Notetaker."""
print("\n=== Getting Notetaker Media ===")

try:
media = nylas.notetakers.get_media(notetaker_id)

if media.recording:
print(f"Recording URL: {media.data.recording.url}")
print(f"Recording Size: {media.data.recording.size} MB")
if media.transcript:
print(f"Transcript URL: {media.data.transcript.url}")
print(f"Transcript Size: {media.data.transcript.size} MB")

return media
except NylasApiError as e:
print(f"Error getting notetaker media: {str(e)}")
raise
except Exception as e:
print(f"Unexpected error in get_notetaker_media: {str(e)}")
raise

def leave_notetaker(notetaker_id):
"""Demonstrates how to leave a Notetaker."""
print("\n=== Leaving Notetaker ===")

try:
nylas.notetakers.leave(notetaker_id)
print(f"Left Notetaker with ID: {notetaker_id}")
except NylasApiError as e:
print(f"Error leaving notetaker: {str(e)}")
raise
except Exception as e:
print(f"Unexpected error in leave_notetaker: {str(e)}")
raise

def main():
"""Main function to run all demo examples."""
try:
# Check for required environment variables
api_key = os.getenv("NYLAS_API_KEY")
if not api_key:
raise ValueError("NYLAS_API_KEY environment variable is not set")
print(f"Using API key: {api_key[:5]}...")

# Invite a Notetaker to a meeting
notetaker = invite_notetaker()

# List all Notetakers
list_notetakers()

# Get media from the Notetaker (if available)
if notetaker.data.state == NotetakerState.MEDIA_AVAILABLE:
get_notetaker_media(notetaker.data.id)

# Leave the Notetaker
leave_notetaker(notetaker.data.id)

except NylasApiError as e:
print(f"\nNylas API Error: {str(e)}")
print(f"Error details: {e.__dict__}")
sys.exit(1)
except ValueError as e:
print(f"\nConfiguration Error: {str(e)}")
sys.exit(1)
except Exception as e:
print(f"\nUnexpected Error: {str(e)}")
print(f"Error type: {type(e)}")
print(f"Error details: {e.__dict__}")
sys.exit(1)

if __name__ == "__main__":
main()
50 changes: 50 additions & 0 deletions examples/notetaker_calendar_demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Notetaker Calendar Integration Demo

This demo showcases how to use the Nylas Notetaker API in conjunction with calendar and event APIs to create and manage notes associated with calendar events.

## Features Demonstrated

- Creating notes linked to calendar events
- Retrieving notes associated with events
- Managing event-related notes
- Syncing notes with event updates
- Using note metadata for event organization

## Prerequisites

- Python 3.8+
- Nylas Python SDK (local version from this repository)
- Nylas API credentials (Client ID and Client Secret)

## Setup

1. Install the SDK in development mode:
```bash
# From the root of the nylas-python repository
pip install -e .
```

2. Set up your environment variables:
```bash
export NYLAS_API_KEY='your_api_key'
export NYLAS_API_URI='https://api.nylas.com' # Optional, defaults to https://api.nylas.com
```

## Running the Demo

From the root of the repository:
```bash
python examples/notetaker_calendar_demo/notetaker_calendar_demo.py
```

## Code Examples

The demo includes examples of:

1. Creating a calendar event with associated notes
2. Retrieving notes linked to specific events
3. Updating event notes when the event changes
4. Managing note metadata for event organization
5. Syncing notes across multiple events

Each example is documented with comments explaining the functionality and expected output.
Loading