Skip to content

v5.0.0

Compare
Choose a tag to compare
@mrashed-dev mrashed-dev released this 21 Jul 21:07

πŸ‘‹ Hey there! It's been a while but we have a new action-packed release for the Python SDK! This new release addresses a lot of issues and bugs. Furthermore we have some new exciting features such as support for the new Nylas Neural API, Event Metadata, and support for new Room Resources fields! Please note that with this release you may need to update your configuration as we have changed the names of the API configuration variables. More information can be found below under "Breaking Changes".

New Features

  • Add support for the Nylas Neural API (#163)
  • Add metadata support (#152)
  • Add new Room Resource fields (#156)
  • Add Nylas-API-Version header support (#157)

Enhancements

  • Transitioned from app_id and app_secret naming to client_id and client_secret (#159)
  • Fix adding a tracking object to an existing draft (#153)
  • Fix issue when converting offset-aware datetime objects to timestamp (#154)
  • Fix limit value in filter not being used when making .all() call (#155)
  • Fix from_ field set by attribute on draft ignored (#162)
  • Remove bumpversion from a required dependency to an extra dependency (#158)

Breaking Changes

API Configuration

The Python SDK previously used the variable names app_id and app_secret for the API configuration. They have now changed to client_id and client_secret. In the other Nylas components like the API and other SDKs the values are referred to as the Client ID and the Client Secret so this change was made for consistency and to reduce confusion.

If you were previously initializing APIClient by passing in the credentials as a variable assignment, you are required to update your code to reflect the new credential variable names:

client = APIClient(
        client_id="CLIENT_ID",
        client_secret="CLIENT_SECRET",
    )

If you were initializing it by just passing in the values in order like so:

client = APIClient(
        "CLIENT_ID",
        "CLIENT_SECRET",
    )

then no change is required on your part.

Using New Features

Neural API

To use Sentiment Analysis:

# To perform sentiment analysis on a message, pass in the list of message ID:
message_analysis = nylas.neural.sentiment_analysis_message([MESSAGE_ID])

# To perform sentiment analysis on just text, pass in a string:
text_analysis = nylas.neural.sentiment_analysis_text("Hi, thank you so much for reaching out! We can catch up tomorrow.")

To use Signature Extraction:

const signature = nylas.neural.extract_signature([MESSAGE_ID])

# The method also accepts two optional parameters
# parseContact, a boolean for whether Nylas should parse the contact from the signature (API defaults to true)
# options, an object of options that can be enabled for the Neural endpoint, of type NeuralMessageOptions:
options = NeuralMessageOptions(
    ignore_links=False,
    ignore_images=False,
    ignore_tables=False,
    remove_conclusion_phrases=False,
    images_as_markdowns=False
)

signature = nylas.neural.extract_signature([MESSAGE_ID], true, options)

and to parse the contact and convert it to the standard Nylas contact object:

contact = signature[0].contacts.to_contact_object()

To use Clean Conversations:

convo = nylas.neural.clean_conversation([MESSAGE_ID])

# You can also pass in an object of options that can be enabled for the Neural endpoint, of type NeuralMessageOptions
convo = nylas.neural.clean_conversation([MESSAGE_ID], options);

and to extract images from the result:

convo[0].extract_images()

To use Optical Character Recognition:

ocr = nylas.neural.ocr_request(FILE_ID)

# This endpoint also supports a second, optional parameter for an array specifying the pages that the user wants analyzed:
ocr = nylas.neural.ocr_request(FILE_ID, [2, 3])

To use Categorizer

cat = nylas.neural.categorize([MESSAGE_ID])

# You can also send a request to recategorize the message:
cat = cat[0].recategorize("conversation")

Event Metadata

# To filter using either metadata_key or metadata_value you can pass in a string:
events = nylas.events.where(metadata_key='hello').all()

# or, you can pass in multiple strings as an array:
events = nylas.events.where(metadata_value=['value1', 'value2']).all()

# To filter on `metadata_pair` you can pass in a `dict` of key-value pairs to use in the query:
events = nylas.events.where(metadata_pair={'hello': 'world'}).all()