--- layout: docs title: Extending the Composer edit_url: "https://github.com/nylas/N1/blob/a2c697754ad692e6a54629ffd93883dda79b0d78/docs/DraftStoreExtensions.md" ---

The composer lies at the heart of N1, and many improvements to the mail experience require deep integration with the composer. To enable these sort of plugins, the DraftStore exposes an extension API.

This API allows your package to:

To create your own composer extensions, subclass DraftStoreExtension and override the methods your extension needs.

In the sample packages repository, templates is an example of a package which uses a DraftStoreExtension to enhance the composer experience.

Example

This extension displays a warning before sending a draft that contains the names of competitors' products. If the user proceeds to send the draft containing the words, it appends a disclaimer.

DraftStoreExtension = require 'nylas-exports'

class ProductsExtension extends DraftStoreExtension

   @warningsForSending: (draft) ->
      words = ['acme', 'anvil', 'tunnel', 'rocket', 'dynamite']
      body = draft.body.toLowercase()
      for word in words
        if body.indexOf(word) > 0
            return ["with the word '#{word}'?"]
      return []

   @finalizeSessionBeforeSending: (session) ->
      draft = session.draft()
      if @warningsForSending(draft)
         bodyWithWarning = draft.body += "<br>This email \
             contains competitor's product names \
            or trademarks used in context."
         session.changes.add(body: bodyWithWarning)