@pipedream/microsoft_outlook
Version:
Pipedream Microsoft Outlook Components
108 lines (106 loc) • 2.55 kB
JavaScript
import microsoftOutlook from "../../microsoft_outlook.app.mjs";
export default {
key: "microsoft_outlook-create-draft-reply",
name: "Create Draft Reply",
description: "Create a draft reply to an email. [See the documentation](https://learn.microsoft.com/en-us/graph/api/message-createreply)",
version: "0.0.10",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
type: "action",
props: {
microsoftOutlook,
userId: {
propDefinition: [
microsoftOutlook,
"userId",
],
optional: true,
description: "The User ID of a shared mailbox. If not provided, defaults to the authenticated user's mailbox.",
},
messageId: {
propDefinition: [
microsoftOutlook,
"messageId",
({ userId }) => ({
userId,
}),
],
},
recipients: {
propDefinition: [
microsoftOutlook,
"recipients",
],
},
ccRecipients: {
propDefinition: [
microsoftOutlook,
"ccRecipients",
],
},
bccRecipients: {
propDefinition: [
microsoftOutlook,
"bccRecipients",
],
},
subject: {
propDefinition: [
microsoftOutlook,
"subject",
],
},
comment: {
propDefinition: [
microsoftOutlook,
"content",
],
description: "Content of the reply in text format",
},
files: {
propDefinition: [
microsoftOutlook,
"files",
],
},
expand: {
propDefinition: [
microsoftOutlook,
"expand",
],
description: "Additional email details, [See object definition](https://docs.microsoft.com/en-us/graph/api/resources/message)",
},
syncDir: {
type: "dir",
accessMode: "read",
sync: true,
optional: true,
},
},
methods: {
async createReply({
userId, messageId, data = {},
} = {}) {
return await this.microsoftOutlook.client().api(`${this.microsoftOutlook._userPath(userId)}/messages/${messageId}/createReply`)
.post(data);
},
},
async run({ $ }) {
const response = await this.createReply({
userId: this.userId,
messageId: this.messageId,
data: {
comment: this.comment,
message: {
...await this.microsoftOutlook.prepareMessageBody(this),
...this.expand,
},
},
});
$.export("$summary", "Reply draft has been created.");
return response;
},
};