Open a composer with a new draft message.
function createDraft(draft: object, cancelToken?: CancelToken): Promise<DraftMessage>;Parameters
Parameter | Type | Description |
|---|---|---|
| Object | Properties of the draft to create. |
| 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. |
| Array of String (optional) | Handles to send the message to. |
| Array of String (optional) | Handles to add in copy of the message. Supported only for email channels. |
| Array of String (optional) | Handles to add in blind copy of the message. Supported only for email channels. |
| String (optional) | Subject of the message. |
| Object (optional) | Content properties of the draft. |
| String | Content of the message. |
| String | Content type of the body. Can be either |
| Array of File (optional) | Files to attach to the message. Must contain absolute file paths. |
| Object (optional) | Options to create a draft from another message. |
| String | Type of the reply. Can be one of |
| String | ID of the message to reply to or forward. |
| 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:
replyto reply to the sender of the original message. Front will address the message to the sender by default.replyAllto reply to all recipients of the original message. Front will reuse its recipients by default.forwardto 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'
});