createDraft

Open a composer with a new draft message.

function createDraft(draft: object, cancelToken?: CancelToken): Promise<DraftMessage>;

Parameters

Parameter

Type

Description

draft

Object

Properties of the draft to create.

draft.channelId

String (optional)

ID of the channel to use to compose the draft. If omitted, Front will apply its internal logic to pick the most relevant channel.

draft.to

Array of String (optional)

Handles to send the message to.

draft.cc

Array of String (optional)

Handles to add in copy of the message. Supported only for email channels.

draft.bcc

Array of String (optional)

Handles to add in blind copy of the message. Supported only for email channels.

draft.subject

String (optional)

Subject of the message.

draft.content

Object (optional)

Content properties of the draft.

draft.content.body

String

Content of the message.

draft.content.type

String

Content type of the body. Can be either html or text.

draft.replyOptions

Object (optional)

Options to create a draft from another message.

draft.replyOptions.type

String

Type of the reply. Can be one of reply, replyAll or forward.

draft.replyOptions.originalMessageId

String

ID of the message to reply to or forward.

cancelToken

CancelToken (optional)

Token to cancel the request.

Content type

The type of the draft.content.body property is defined in draft.content.type. It can be either text or html.
Front will convert the content in a format that matches the teammate's composer preferences.

Reply options

By default, createDraft will open a composer for a new message.
To create a reply or forward a message, the function accepts an optional draft.replyOptions object. with a originalMessageId and a type. The type property can be one of:

  • reply to reply to the sender of the original message. Front will address the message to the sender by default.
  • replyAll to reply to all recipients of the original message. Front will reuse its recipients by default.
  • forward to forward the original message. Front will reuse its content by default.

Return value

The function returns a promise that resolves with the Draft created.

Examples

const draft = await Front.createDraft({
  to: ['[email protected]'],
  content: {
    body: 'Hello world',
    type: 'text'
  }
});
const draft = await Front.createDraft({
  content: {
    body: 'Hello world',
    type: 'text'
  },
  replyOptions: {
    type: 'reply', // Or 'replyAll'
    originalMessageId: 'msg_xxx'
});
const draft = await Front.createDraft({
  replyOptions: {
    type: 'forward',
    originalMessageId: 'msg_xxx'
});