github nylas/nylas-nodejs v5.6.0

latest releases: v7.5.2, v7.5.1, v7.5.0...
3 years ago

This new release of the Nylas Node SDK brings a couple of fixes as well as adding a few features. Most notably, this release brings forward support for the Nylas Neural API! More information below on how to use each part of the Neural API through our Node SDK.

New Features

  • Add linting, enabled and set up eslint and prettier (#252)
  • Add support for /calendars/availability endpoint (#248, #254)
  • Add support for the Neural API (#253)

Enhancements

  • Fix Jest test cases not respecting async methods (#249)
  • Fix issue with parsing raw MIME emails (#247)

Using New Features

Neural API

To use Sentiment Analysis:

// To perform sentiment analysis on a message, pass in the message ID:
const messageAnalysis = await nylas.neural.sentimentAnalysisMessage(MESSAGE_ID);

// To perform sentiment analysis on just text, pass in a string:
const textAnalysis = await nylas.neural.sentimentAnalysisText("Hi, thank you so much for reaching out! We can catch up tomorrow.");

To use Signature Extraction:

const signature = await nylas.neural.extractSignature(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:
const options = {
    ignore_links: false,
    ignore_images: false,
    ignore_tables: false,
    remove_conclusion_phrases: false,
    images_as_markdowns: false
}

const signature = await nylas.neural.extractSignature(MESSAGE_ID, true, options);

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

const contact = signature.contacts.toContactObject();

To use Clean Conversations:

const convo = await nylas.neural.cleanConversation(MESSAGE_ID);

// You can also pass in an object of options that can be enabled for the Neural endpoint, of type NeuralMessageOptions
const convo = await nylas.neural.cleanConversation(MESSAGE_ID, options);

and to extract images from the result:

await convo.extractImages();

To use Optical Character Recognition:

const ocr = await nylas.neural.ocrRequest(FILE_ID);

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

To use Categorizer

let cat = await nylas.neural.categorize(MESSAGE_ID);

// You can also send a request to recategorize the message:
cat = await cat.reCategorize("conversation");

Calendar Availaiblity

const params = {
  startTime: '1590454800',
  endTime: '1590780800',
  interval: 5,
  duration: 30,
  emails: ['jane@email.com'],
  open_hours: [
    {
      emails: ['swag@nylas.com'],
      days: ['0'],
      timezone: 'America/Chicago',
      start: '10:00',
      end: '14:00',
      object_type: 'open_hours',
    },
  ],
};

const availability = await testContext.connection.calendars.availability(params);

Don't miss a new nylas-nodejs release

NewReleases is sending notifications on new releases.