@divyacon/piece-microsoft-outlook 0.1.1 → 0.7.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/package.json +9 -27
  2. package/src/i18n/de.json +298 -0
  3. package/src/i18n/es.json +298 -0
  4. package/src/i18n/fr.json +298 -0
  5. package/src/i18n/ja.json +298 -0
  6. package/src/i18n/nl.json +298 -0
  7. package/src/i18n/pt.json +298 -0
  8. package/src/i18n/ru.json +41 -0
  9. package/src/i18n/translation.json +298 -0
  10. package/src/i18n/vi.json +41 -0
  11. package/src/i18n/zh.json +298 -0
  12. package/src/index.js +77 -0
  13. package/dist/index.d.ts +0 -2
  14. package/dist/index.d.ts.map +0 -1
  15. package/dist/index.js +0 -65
  16. package/dist/index.js.map +0 -1
  17. package/dist/lib/actions/add-label-to-email.d.ts +0 -5
  18. package/dist/lib/actions/add-label-to-email.d.ts.map +0 -1
  19. package/dist/lib/actions/add-label-to-email.js +0 -44
  20. package/dist/lib/actions/add-label-to-email.js.map +0 -1
  21. package/dist/lib/actions/create-draft-email.d.ts +0 -10
  22. package/dist/lib/actions/create-draft-email.d.ts.map +0 -1
  23. package/dist/lib/actions/create-draft-email.js +0 -108
  24. package/dist/lib/actions/create-draft-email.js.map +0 -1
  25. package/dist/lib/actions/download-email-attachment.d.ts +0 -4
  26. package/dist/lib/actions/download-email-attachment.d.ts.map +0 -1
  27. package/dist/lib/actions/download-email-attachment.js +0 -44
  28. package/dist/lib/actions/download-email-attachment.js.map +0 -1
  29. package/dist/lib/actions/find-email.d.ts +0 -6
  30. package/dist/lib/actions/find-email.d.ts.map +0 -1
  31. package/dist/lib/actions/find-email.js +0 -67
  32. package/dist/lib/actions/find-email.js.map +0 -1
  33. package/dist/lib/actions/forward-email.d.ts +0 -6
  34. package/dist/lib/actions/forward-email.d.ts.map +0 -1
  35. package/dist/lib/actions/forward-email.js +0 -61
  36. package/dist/lib/actions/forward-email.js.map +0 -1
  37. package/dist/lib/actions/move-email-to-folder.d.ts +0 -5
  38. package/dist/lib/actions/move-email-to-folder.d.ts.map +0 -1
  39. package/dist/lib/actions/move-email-to-folder.js +0 -41
  40. package/dist/lib/actions/move-email-to-folder.js.map +0 -1
  41. package/dist/lib/actions/remove-label-from-email.d.ts +0 -5
  42. package/dist/lib/actions/remove-label-from-email.d.ts.map +0 -1
  43. package/dist/lib/actions/remove-label-from-email.js +0 -44
  44. package/dist/lib/actions/remove-label-from-email.js.map +0 -1
  45. package/dist/lib/actions/reply-email.d.ts +0 -10
  46. package/dist/lib/actions/reply-email.d.ts.map +0 -1
  47. package/dist/lib/actions/reply-email.js +0 -161
  48. package/dist/lib/actions/reply-email.js.map +0 -1
  49. package/dist/lib/actions/request-approval-send-email.d.ts +0 -6
  50. package/dist/lib/actions/request-approval-send-email.d.ts.map +0 -1
  51. package/dist/lib/actions/request-approval-send-email.js +0 -99
  52. package/dist/lib/actions/request-approval-send-email.js.map +0 -1
  53. package/dist/lib/actions/send-draft-email.d.ts +0 -4
  54. package/dist/lib/actions/send-draft-email.d.ts.map +0 -1
  55. package/dist/lib/actions/send-draft-email.js +0 -38
  56. package/dist/lib/actions/send-draft-email.js.map +0 -1
  57. package/dist/lib/actions/send-email.d.ts +0 -10
  58. package/dist/lib/actions/send-email.d.ts.map +0 -1
  59. package/dist/lib/actions/send-email.js +0 -111
  60. package/dist/lib/actions/send-email.js.map +0 -1
  61. package/dist/lib/common/auth.d.ts +0 -2
  62. package/dist/lib/common/auth.d.ts.map +0 -1
  63. package/dist/lib/common/auth.js +0 -88
  64. package/dist/lib/common/auth.js.map +0 -1
  65. package/dist/lib/common/client.d.ts +0 -16
  66. package/dist/lib/common/client.d.ts.map +0 -1
  67. package/dist/lib/common/client.js +0 -27
  68. package/dist/lib/common/client.js.map +0 -1
  69. package/dist/lib/common/microsoft-cloud.d.ts +0 -6
  70. package/dist/lib/common/microsoft-cloud.d.ts.map +0 -1
  71. package/dist/lib/common/microsoft-cloud.js +0 -57
  72. package/dist/lib/common/microsoft-cloud.js.map +0 -1
  73. package/dist/lib/common/props.d.ts +0 -10
  74. package/dist/lib/common/props.d.ts.map +0 -1
  75. package/dist/lib/common/props.js +0 -124
  76. package/dist/lib/common/props.js.map +0 -1
  77. package/dist/lib/triggers/new-attachment.d.ts +0 -19
  78. package/dist/lib/triggers/new-attachment.d.ts.map +0 -1
  79. package/dist/lib/triggers/new-attachment.js +0 -129
  80. package/dist/lib/triggers/new-attachment.js.map +0 -1
  81. package/dist/lib/triggers/new-email-in-folder.d.ts +0 -11
  82. package/dist/lib/triggers/new-email-in-folder.d.ts.map +0 -1
  83. package/dist/lib/triggers/new-email-in-folder.js +0 -96
  84. package/dist/lib/triggers/new-email-in-folder.js.map +0 -1
  85. package/dist/lib/triggers/new-email.d.ts +0 -15
  86. package/dist/lib/triggers/new-email.d.ts.map +0 -1
  87. package/dist/lib/triggers/new-email.js +0 -120
  88. package/dist/lib/triggers/new-email.js.map +0 -1
  89. package/src/index.ts +0 -56
  90. package/src/lib/actions/add-label-to-email.ts +0 -41
  91. package/src/lib/actions/create-draft-email.ts +0 -106
  92. package/src/lib/actions/download-email-attachment.ts +0 -47
  93. package/src/lib/actions/find-email.ts +0 -72
  94. package/src/lib/actions/forward-email.ts +0 -64
  95. package/src/lib/actions/move-email-to-folder.ts +0 -36
  96. package/src/lib/actions/remove-label-from-email.ts +0 -43
  97. package/src/lib/actions/reply-email.ts +0 -158
  98. package/src/lib/actions/request-approval-send-email.ts +0 -105
  99. package/src/lib/actions/send-draft-email.ts +0 -33
  100. package/src/lib/actions/send-email.ts +0 -110
  101. package/src/lib/common/auth.ts +0 -85
  102. package/src/lib/common/client.ts +0 -26
  103. package/src/lib/common/microsoft-cloud.ts +0 -56
  104. package/src/lib/common/props.ts +0 -137
  105. package/src/lib/triggers/new-attachment.ts +0 -153
  106. package/src/lib/triggers/new-email-in-folder.ts +0 -95
  107. package/src/lib/triggers/new-email.ts +0 -126
@@ -1,120 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.newEmailTrigger = void 0;
4
- const tslib_1 = require("tslib");
5
- // Vendored from Activepieces packages/pieces/community/microsoft-outlook/src/lib/triggers/new-email.ts (MIT).
6
- // Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
7
- const pieces_common_1 = require("@agnocon/pieces-common");
8
- const pieces_framework_1 = require("@agnocon/pieces-framework");
9
- const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
10
- const auth_1 = require("../common/auth");
11
- const client_1 = require("../common/client");
12
- const polling = {
13
- strategy: pieces_common_1.DedupeStrategy.TIMEBASED,
14
- items: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, lastFetchEpochMS, propsValue }) {
15
- const client = client_1.outlookCommon.createClient(auth);
16
- const messages = [];
17
- const filter = lastFetchEpochMS === 0
18
- ? '$top=10'
19
- : `$filter=receivedDateTime gt ${(0, dayjs_1.default)(lastFetchEpochMS).toISOString()}`;
20
- let response = yield client
21
- .api(`${client_1.outlookCommon.mailboxPrefix(auth)}/mailFolders/inbox/messages?${filter}`)
22
- .orderby('receivedDateTime desc')
23
- .get();
24
- if (lastFetchEpochMS === 0) {
25
- for (const message of response.value) {
26
- messages.push(message);
27
- }
28
- }
29
- else {
30
- while (response.value.length > 0) {
31
- for (const message of response.value) {
32
- messages.push(message);
33
- }
34
- if (response['@odata.nextLink']) {
35
- response = yield client.api(response['@odata.nextLink']).get();
36
- }
37
- else {
38
- break;
39
- }
40
- }
41
- }
42
- let filteredMessages = messages;
43
- if (propsValue === null || propsValue === void 0 ? void 0 : propsValue.sender) {
44
- filteredMessages = filteredMessages.filter((message) => {
45
- var _a, _b, _c, _d;
46
- const messageSenderEmail = (_c = (_b = (_a = message.from) === null || _a === void 0 ? void 0 : _a.emailAddress) === null || _b === void 0 ? void 0 : _b.address) === null || _c === void 0 ? void 0 : _c.toLowerCase();
47
- const filterSenderEmail = (_d = propsValue.sender) === null || _d === void 0 ? void 0 : _d.toLowerCase();
48
- return messageSenderEmail === filterSenderEmail;
49
- });
50
- }
51
- if (propsValue === null || propsValue === void 0 ? void 0 : propsValue.recipient) {
52
- filteredMessages = filteredMessages.filter((message) => {
53
- var _a;
54
- const hasRecipient = (_a = message.toRecipients) === null || _a === void 0 ? void 0 : _a.some((recipient) => {
55
- var _a, _b, _c;
56
- const recipientEmail = (_b = (_a = recipient.emailAddress) === null || _a === void 0 ? void 0 : _a.address) === null || _b === void 0 ? void 0 : _b.toLowerCase();
57
- const filterRecipientEmail = (_c = propsValue.recipient) === null || _c === void 0 ? void 0 : _c.toLowerCase();
58
- return recipientEmail === filterRecipientEmail;
59
- });
60
- return hasRecipient;
61
- });
62
- }
63
- return filteredMessages.map((message) => ({
64
- epochMilliSeconds: (0, dayjs_1.default)(message.receivedDateTime).valueOf(),
65
- data: message,
66
- }));
67
- }),
68
- };
69
- exports.newEmailTrigger = (0, pieces_framework_1.createTrigger)({
70
- auth: auth_1.microsoftOutlookAuth,
71
- name: 'newEmail',
72
- displayName: 'New Email',
73
- description: 'Triggers when a new email is received in the inbox.',
74
- aiMetadata: {
75
- description: 'Fires when a new message arrives in the mailbox Inbox, optionally narrowed to a specific sender and/or recipient address. Each fire represents one newly received email.',
76
- },
77
- props: {
78
- sender: pieces_framework_1.Property.ShortText({
79
- displayName: 'From (Sender Email)',
80
- description: 'Filter emails from a specific sender (optional). Leave empty to for all senders.',
81
- required: false,
82
- }),
83
- recipient: pieces_framework_1.Property.ShortText({
84
- displayName: 'To (Recipient Email)',
85
- description: 'Filter emails to a specific recipient (optional). Leave empty to for all recipients.',
86
- required: false,
87
- }),
88
- },
89
- sampleData: {},
90
- type: pieces_framework_1.TriggerStrategy.POLLING,
91
- onEnable(context) {
92
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
93
- yield pieces_common_1.pollingHelper.onEnable(polling, {
94
- auth: context.auth,
95
- store: context.store,
96
- propsValue: context.propsValue,
97
- });
98
- });
99
- },
100
- onDisable(context) {
101
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
102
- yield pieces_common_1.pollingHelper.onDisable(polling, {
103
- auth: context.auth,
104
- store: context.store,
105
- propsValue: context.propsValue,
106
- });
107
- });
108
- },
109
- test(context) {
110
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
111
- return yield pieces_common_1.pollingHelper.test(polling, context);
112
- });
113
- },
114
- run(context) {
115
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
116
- return yield pieces_common_1.pollingHelper.poll(polling, context);
117
- });
118
- },
119
- });
120
- //# sourceMappingURL=new-email.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"new-email.js","sourceRoot":"","sources":["../../../src/lib/triggers/new-email.ts"],"names":[],"mappings":";;;;AAAA,8GAA8G;AAC9G,qEAAqE;AACrE,0DAAgF;AAChF,gEAKmC;AAGnC,0DAA0B;AAC1B,yCAAsD;AACtD,6CAAiD;AAEjD,MAAM,OAAO,GAGR;IACJ,QAAQ,EAAE,8BAAc,CAAC,SAAS;IAClC,KAAK,EAAE,KAA+C,EAAE,oDAA1C,EAAE,IAAI,EAAE,gBAAgB,EAAE,UAAU,EAAE;QACnD,MAAM,MAAM,GAAG,sBAAa,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAEhD,MAAM,QAAQ,GAAG,EAAE,CAAC;QACpB,MAAM,MAAM,GACX,gBAAgB,KAAK,CAAC;YACrB,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,+BAA+B,IAAA,eAAK,EAAC,gBAAgB,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;QAE3E,IAAI,QAAQ,GAAmB,MAAM,MAAM;aACzC,GAAG,CAAC,GAAG,sBAAa,CAAC,aAAa,CAAC,IAAI,CAAC,+BAA+B,MAAM,EAAE,CAAC;aAChF,OAAO,CAAC,uBAAuB,CAAC;aAChC,GAAG,EAAE,CAAC;QAER,IAAI,gBAAgB,KAAK,CAAC,EAAE,CAAC;YAC5B,KAAK,MAAM,OAAO,I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EAAE,OAAO,CAAC,UAAU;aAC9B,CAAC,CAAC;QACJ,CAAC;KAAA;IACK,SAAS,CAAC,OAAO;;YACtB,MAAM,6BAAa,CAAC,SAAS,CAAC,OAAO,EAAE;gBACtC,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,UAAU,EAAE,OAAO,CAAC,UAAU;aAC9B,CAAC,CAAC;QACJ,CAAC;KAAA;IACK,IAAI,CAAC,OAAO;;YACjB,OAAO,MAAM,6BAAa,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACnD,CAAC;KAAA;IACK,GAAG,CAAC,OAAO;;YAChB,OAAO,MAAM,6BAAa,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACnD,CAAC;KAAA;CACD,CAAC,CAAC"}
package/src/index.ts DELETED
@@ -1,56 +0,0 @@
1
- import { createCustomApiCallAction } from '@agnocon/pieces-common';
2
- import { getGraphBaseUrl } from './lib/common/microsoft-cloud';
3
- import { createPiece, OAuth2PropertyValue } from '@agnocon/pieces-framework';
4
- import { PieceCategory } from '@agnocon/pieces-framework';
5
- import { addLabelToEmailAction } from './lib/actions/add-label-to-email';
6
- import { createDraftEmailAction } from './lib/actions/create-draft-email';
7
- import { downloadAttachmentAction } from './lib/actions/download-email-attachment';
8
- import { findEmailAction } from './lib/actions/find-email';
9
- import { forwardEmailAction } from './lib/actions/forward-email';
10
- import { moveEmailToFolderAction } from './lib/actions/move-email-to-folder';
11
- import { removeLabelFromEmailAction } from './lib/actions/remove-label-from-email';
12
- import { replyEmailAction } from './lib/actions/reply-email';
13
- import { sendDraftEmailAction } from './lib/actions/send-draft-email';
14
- import { sendEmailAction } from './lib/actions/send-email';
15
- import { microsoftOutlookAuth } from './lib/common/auth';
16
- import { newAttachmentTrigger } from './lib/triggers/new-attachment';
17
- import { newEmailInFolderTrigger } from './lib/triggers/new-email-in-folder';
18
- import { newEmailTrigger } from './lib/triggers/new-email';
19
- import { requestApprovalInMail } from './lib/actions/request-approval-send-email';
20
-
21
- export const microsoftOutlook = createPiece({
22
- displayName: 'Microsoft Outlook',
23
- auth: microsoftOutlookAuth,
24
- minimumSupportedRelease: '0.87.0',
25
- logoUrl: 'https://cdn.activepieces.com/pieces/microsoft-outlook.png',
26
- categories: [PieceCategory.PRODUCTIVITY],
27
- authors: ['lucaslimasouza', 'kishanprmr', 'sanket-a11y'],
28
- actions: [
29
- sendEmailAction,
30
- downloadAttachmentAction,
31
- replyEmailAction,
32
- createDraftEmailAction,
33
- addLabelToEmailAction,
34
- removeLabelFromEmailAction,
35
- requestApprovalInMail,
36
- moveEmailToFolderAction,
37
- sendDraftEmailAction,
38
- forwardEmailAction,
39
- findEmailAction,
40
- createCustomApiCallAction({
41
- auth: microsoftOutlookAuth,
42
- baseUrl: (auth) => {
43
- const cloud = (auth as OAuth2PropertyValue).props?.['cloud'] as string | undefined;
44
- return getGraphBaseUrl(cloud) + '/v1.0/';
45
- },
46
- authMapping: async (auth) => ({
47
- Authorization: `Bearer ${(auth as OAuth2PropertyValue).access_token}`,
48
- }),
49
- }),
50
- ],
51
- triggers: [
52
- newEmailTrigger,
53
- newEmailInFolderTrigger,
54
- newAttachmentTrigger,
55
- ],
56
- });
@@ -1,41 +0,0 @@
1
- import { createAction, Property } from '@agnocon/pieces-framework';
2
- import { microsoftOutlookAuth } from '../common/auth';
3
- import { outlookCommon } from '../common/client';
4
- import { messageIdDropdown } from '../common/props';
5
-
6
- export const addLabelToEmailAction = createAction({
7
- auth: microsoftOutlookAuth,
8
- name: 'addLabelToEmail',
9
- displayName: 'Add Label to Email',
10
- description: 'Adds a category (label) to an email message.',
11
- audience: 'both',
12
- aiMetadata: { description: 'Adds one or more Outlook categories (labels) to a specific message, merging them with any categories already present. Use this to tag or classify an email. Idempotent: re-adding the same categories leaves the message unchanged since duplicates are de-duplicated.', idempotent: true },
13
- props: {
14
- messageId: messageIdDropdown({
15
- displayName: 'Email',
16
- description: 'Select the email message to add the label to.',
17
- required: true,
18
- }),
19
- categories: Property.Array({
20
- displayName: 'Categories',
21
- description: 'Categories to add to the email.',
22
- required: true,
23
- }),
24
- },
25
- async run(context) {
26
- const { messageId, categories } = context.propsValue;
27
-
28
- const client = outlookCommon.createClient(context.auth);
29
-
30
- const message = await client.api(`${outlookCommon.mailboxPrefix(context.auth)}/messages/${messageId}`).get();
31
- const existingCategories = message.categories || [];
32
-
33
- const updatedCategories = [...new Set([...existingCategories, ...categories])];
34
-
35
- const response = await client.api(`${outlookCommon.mailboxPrefix(context.auth)}/messages/${messageId}`).patch({
36
- categories: updatedCategories,
37
- });
38
-
39
- return response;
40
- },
41
- });
@@ -1,106 +0,0 @@
1
- import { ApFile, createAction, Property } from '@agnocon/pieces-framework';
2
- import { BodyType, Message } from '@microsoft/microsoft-graph-types';
3
- import { microsoftOutlookAuth } from '../common/auth';
4
- import { outlookCommon } from '../common/client';
5
-
6
- export const createDraftEmailAction = createAction({
7
- auth: microsoftOutlookAuth,
8
- name: 'createDraftEmail',
9
- displayName: 'Create Draft Email',
10
- description: 'Creates a draft email message.',
11
- audience: 'both',
12
- aiMetadata: { description: 'Creates a new unsent draft email in the Outlook mailbox with recipients, subject, body, and optional attachments. Use this to stage a message for later review or sending (pair with Send Draft Email). Not idempotent: each call creates a separate draft.', idempotent: false },
13
- props: {
14
- recipients: Property.Array({
15
- displayName: 'To Email(s)',
16
- required: true,
17
- }),
18
- ccRecipients: Property.Array({
19
- displayName: 'CC Email(s)',
20
- required: false,
21
- defaultValue: [],
22
- }),
23
- bccRecipients: Property.Array({
24
- displayName: 'BCC Email(s)',
25
- required: false,
26
- defaultValue: [],
27
- }),
28
- subject: Property.ShortText({
29
- displayName: 'Subject',
30
- required: true,
31
- }),
32
- bodyFormat: Property.StaticDropdown({
33
- displayName: 'Body Format',
34
- required: true,
35
- defaultValue: 'text',
36
- options: {
37
- disabled: false,
38
- options: [
39
- { label: 'HTML', value: 'html' },
40
- { label: 'Text', value: 'text' },
41
- ],
42
- },
43
- }),
44
- body: Property.LongText({
45
- displayName: 'Body',
46
- required: true,
47
- }),
48
- attachments: Property.Array({
49
- displayName: 'Attachments',
50
- required: false,
51
- defaultValue: [],
52
- properties: {
53
- file: Property.File({
54
- displayName: 'File',
55
- required: true,
56
- }),
57
- fileName: Property.ShortText({
58
- displayName: 'File Name',
59
- required: false,
60
- }),
61
- },
62
- }),
63
- },
64
- async run(context) {
65
- const recipients = context.propsValue.recipients as string[];
66
- const ccRecipients = context.propsValue.ccRecipients as string[];
67
- const bccRecipients = context.propsValue.bccRecipients as string[];
68
- const attachments = context.propsValue.attachments as Array<{ file: ApFile; fileName: string }>;
69
-
70
- const { subject, body, bodyFormat } = context.propsValue;
71
-
72
- const mailPayload: Message = {
73
- subject,
74
- body: {
75
- content: body,
76
- contentType: bodyFormat as BodyType,
77
- },
78
- toRecipients: recipients.map((mail) => ({
79
- emailAddress: {
80
- address: mail,
81
- },
82
- })),
83
- ccRecipients: ccRecipients.map((mail) => ({
84
- emailAddress: {
85
- address: mail,
86
- },
87
- })),
88
- bccRecipients: bccRecipients.map((mail) => ({
89
- emailAddress: {
90
- address: mail,
91
- },
92
- })),
93
- attachments: attachments.map((attachment) => ({
94
- '@odata.type': '#microsoft.graph.fileAttachment',
95
- name: attachment.fileName || attachment.file.filename,
96
- contentBytes: attachment.file.base64,
97
- })),
98
- };
99
-
100
- const client = outlookCommon.createClient(context.auth);
101
-
102
- const response = await client.api(`${outlookCommon.mailboxPrefix(context.auth)}/messages`).post(mailPayload);
103
-
104
- return response;
105
- },
106
- });
@@ -1,47 +0,0 @@
1
- import { createAction, Property } from '@agnocon/pieces-framework';
2
- import { PageCollection } from '@microsoft/microsoft-graph-client';
3
- import { FileAttachment } from '@microsoft/microsoft-graph-types';
4
- import { microsoftOutlookAuth } from '../common/auth';
5
- import { outlookCommon } from '../common/client';
6
-
7
- export const downloadAttachmentAction = createAction({
8
- auth: microsoftOutlookAuth,
9
- name: 'downloadAttachment',
10
- displayName: 'Download Attachment',
11
- description: 'Download attachments from a specific email message.',
12
- audience: 'both',
13
- aiMetadata: { description: 'Fetches all file attachments from a specific Outlook message (by message ID) and writes them to storage for downstream steps. Use this after locating a message to retrieve its attached files. Requires a valid message ID; idempotent since it only reads.', idempotent: true },
14
- props: {
15
- messageId: Property.ShortText({
16
- displayName: 'Message ID',
17
- description: 'The ID of the email message containing the attachment.',
18
- required: true,
19
- }),
20
- },
21
- async run(context) {
22
- const { messageId } = context.propsValue;
23
-
24
- const client = outlookCommon.createClient(context.auth);
25
-
26
- const response: PageCollection = await client
27
- .api(`${outlookCommon.mailboxPrefix(context.auth)}/messages/${messageId}/attachments`)
28
- .get();
29
-
30
- const attachments = [];
31
-
32
- for (const attachment of response.value as FileAttachment[]) {
33
- if (attachment.name && attachment.contentBytes) {
34
- attachments.push({
35
- ...attachment,
36
- file: await context.files.write({
37
- fileName: attachment.name || 'test.png',
38
- data: Buffer.from(attachment.contentBytes, 'base64'),
39
- }),
40
- });
41
- }
42
- }
43
-
44
-
45
- return attachments;
46
- },
47
- });
@@ -1,72 +0,0 @@
1
- import { createAction, Property } from '@agnocon/pieces-framework';
2
- import { PageCollection } from '@microsoft/microsoft-graph-client';
3
- import { Message } from '@microsoft/microsoft-graph-types';
4
- import dayjs from 'dayjs';
5
- import { microsoftOutlookAuth } from '../common/auth';
6
- import { outlookCommon } from '../common/client';
7
- import { mailFolderIdDropdown } from '../common/props';
8
-
9
- export const findEmailAction = createAction({
10
- auth: microsoftOutlookAuth,
11
- name: 'findEmail',
12
- displayName: 'Find Email',
13
- description: 'Searches for emails using full-text search.',
14
- audience: 'both',
15
- aiMetadata: { description: 'Searches the Outlook mailbox for messages matching a full-text query (supports field syntax like from:, subject:, hasAttachments:), optionally scoped to one folder and capped by a max-results count. Use this to locate emails and obtain their message IDs for follow-up actions. Idempotent read-only lookup.', idempotent: true },
16
- props: {
17
- searchQuery: Property.ShortText({
18
- displayName: 'Search Query',
19
- description:
20
- 'Search terms to find emails (e.g., "from:john@example.com", "subject:urgent", "hasAttachments:true")',
21
- required: true,
22
- }),
23
- folderId: mailFolderIdDropdown({
24
- displayName: 'Folder',
25
- description: 'Search in a specific folder. Leave empty to search all folders.',
26
- required: false,
27
- }),
28
- top: Property.Number({
29
- displayName: 'Max Results',
30
- description: 'Maximum number of results to return (1-1000).',
31
- required: false,
32
- defaultValue: 25,
33
- }),
34
- },
35
- async run(context) {
36
- const { searchQuery, folderId, top } = context.propsValue;
37
-
38
- const client = outlookCommon.createClient(context.auth);
39
-
40
- const baseUrl = folderId ? `${outlookCommon.mailboxPrefix(context.auth)}/mailFolders/${folderId}/messages` : `${outlookCommon.mailboxPrefix(context.auth)}/messages`;
41
- const searchParam = `$search="${searchQuery}"`;
42
- const topParam = top ? `$top=${Math.min(Math.max(top, 1), 1000)}` : '$top=25';
43
- const selectParam = ['id', 'subject', 'from', 'toRecipients', 'receivedDateTime'].join(',');
44
-
45
- const queryParams = [searchParam, topParam, selectParam].filter(Boolean).join('&');
46
- const url = `${baseUrl}?${queryParams}`;
47
-
48
- const headers: Record<string, string> = {
49
- ConsistencyLevel: 'eventual',
50
- Prefer: 'outlook.body-content-type="text"',
51
- };
52
-
53
- const response: PageCollection = await client.api(url).headers(headers).get();
54
-
55
- const messages = response.value as Message[];
56
- const nextPageUrl = response['@odata.nextLink'];
57
-
58
- if (searchQuery) {
59
- messages.sort(
60
- (a, b) => dayjs(b.receivedDateTime).valueOf() - dayjs(a.receivedDateTime).valueOf(),
61
- );
62
- }
63
-
64
- return {
65
- found: messages.length > 0,
66
- result: messages,
67
- hasMore: !!nextPageUrl,
68
- nextPageUrl: nextPageUrl,
69
- totalCount: messages.length,
70
- };
71
- },
72
- });
@@ -1,64 +0,0 @@
1
- import { createAction, Property } from '@agnocon/pieces-framework';
2
- import { BodyType, Message } from '@microsoft/microsoft-graph-types';
3
- import { microsoftOutlookAuth } from '../common/auth';
4
- import { outlookCommon } from '../common/client';
5
- import { messageIdDropdown } from '../common/props';
6
-
7
- export const forwardEmailAction = createAction({
8
- auth: microsoftOutlookAuth,
9
- name: 'forwardEmail',
10
- displayName: 'Forward Email',
11
- description: 'Forwards an email message.',
12
- audience: 'both',
13
- aiMetadata: { description: 'Forwards an existing Outlook message (by message ID) to new recipients, preserving the original body and attachments and prepending an optional comment. Use this to pass an existing email along rather than composing a new one. Not idempotent: each call sends a new forwarded email.', idempotent: false },
14
- props: {
15
- messageId: messageIdDropdown({
16
- displayName: 'Email',
17
- description: 'Select the email message to forward.',
18
- required: true,
19
- }),
20
- recipients: Property.Array({
21
- displayName: 'To Email(s)',
22
- required: true,
23
- }),
24
- comment: Property.LongText({
25
- displayName: 'Comment',
26
- description: 'Optional comment to include with the forwarded message.',
27
- required: false,
28
- }),
29
- },
30
- async run(context) {
31
- const { messageId, comment } = context.propsValue;
32
- const recipients = context.propsValue.recipients as string[];
33
-
34
- const client = outlookCommon.createClient(context.auth);
35
-
36
- const message = await client.api(`${outlookCommon.mailboxPrefix(context.auth)}/messages/${messageId}`).get();
37
-
38
- const messagePayload: Message = {
39
- toRecipients: recipients.map((mail) => ({
40
- emailAddress: {
41
- address: mail,
42
- },
43
- })),
44
- body: {
45
- contentType: 'html',
46
- content: (comment ?? '') + '<br><br>' + message.body.content,
47
- },
48
- attachments: message.attachments,
49
- };
50
-
51
- const response = await client
52
- .api(`${outlookCommon.mailboxPrefix(context.auth)}/messages/${messageId}/forward`)
53
- .post({
54
- message:messagePayload,
55
- });
56
-
57
- return {
58
- success: true,
59
- message: 'Email forwarded successfully.',
60
- messageId: response.id,
61
- ...response,
62
- };
63
- },
64
- });
@@ -1,36 +0,0 @@
1
- import { createAction, Property } from '@agnocon/pieces-framework';
2
- import { microsoftOutlookAuth } from '../common/auth';
3
- import { outlookCommon } from '../common/client';
4
- import { mailFolderIdDropdown, messageIdDropdown } from '../common/props';
5
-
6
- export const moveEmailToFolderAction = createAction({
7
- auth: microsoftOutlookAuth,
8
- name: 'moveEmailToFolder',
9
- displayName: 'Move Email to Folder',
10
- description: 'Moves an email message to a specific folder.',
11
- audience: 'both',
12
- aiMetadata: { description: 'Moves a specific Outlook message into a chosen mail folder. Use this to organize, archive, or route an email after processing it. Note: the move assigns a new message ID, so re-running with the original ID will fail once moved.', idempotent: false },
13
- props: {
14
- messageId: messageIdDropdown({
15
- displayName: 'Email',
16
- description: 'Select the email message to move.',
17
- required: true,
18
- }),
19
- destinationFolderId: mailFolderIdDropdown({
20
- displayName: 'Destination Folder',
21
- description: 'The folder to move the email to.',
22
- required: true,
23
- }),
24
- },
25
- async run(context) {
26
- const { messageId, destinationFolderId } = context.propsValue;
27
-
28
- const client = outlookCommon.createClient(context.auth);
29
-
30
- const response = await client.api(`${outlookCommon.mailboxPrefix(context.auth)}/messages/${messageId}/move`).post({
31
- destinationId: destinationFolderId,
32
- });
33
-
34
- return response;
35
- },
36
- });
@@ -1,43 +0,0 @@
1
- import { createAction, Property } from '@agnocon/pieces-framework';
2
- import { microsoftOutlookAuth } from '../common/auth';
3
- import { outlookCommon } from '../common/client';
4
- import { messageIdDropdown } from '../common/props';
5
-
6
- export const removeLabelFromEmailAction = createAction({
7
- auth: microsoftOutlookAuth,
8
- name: 'removeLabelFromEmail',
9
- displayName: 'Remove Label from Email',
10
- description: 'Removes a category (label) from an email message.',
11
- audience: 'both',
12
- aiMetadata: { description: 'Removes one or more Outlook categories (labels) from a specific message, leaving any other categories intact. Use this to untag or reclassify an email. Idempotent: re-running with the same categories yields the same final label set.', idempotent: true },
13
- props: {
14
- messageId: messageIdDropdown({
15
- displayName: 'Email',
16
- description: 'Select the email message to remove the label from.',
17
- required: true,
18
- }),
19
- categories: Property.Array({
20
- displayName: 'Categories to Remove',
21
- description: 'Categories to remove from the email.',
22
- required: true,
23
- }),
24
- },
25
- async run(context) {
26
- const { messageId, categories } = context.propsValue;
27
-
28
- const client = outlookCommon.createClient(context.auth);
29
-
30
- const message = await client.api(`${outlookCommon.mailboxPrefix(context.auth)}/messages/${messageId}`).get();
31
- const existingCategories = message.categories || [];
32
-
33
- const updatedCategories = existingCategories.filter(
34
- (category: string) => !categories.includes(category)
35
- );
36
-
37
- const response = await client.api(`${outlookCommon.mailboxPrefix(context.auth)}/messages/${messageId}`).patch({
38
- categories: updatedCategories,
39
- });
40
-
41
- return response;
42
- },
43
- });