@pipedream/microsoft_outlook_calendar 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Overview
2
2
 
3
- With the Microsoft Outlook API, you can build a wide range of applications and
4
- services that work with Outlook. The Microsoft Outlook Calendar app helps you
5
- manage your calendar and schedule appointments.
3
+ The Microsoft Outlook Calendar API provides programmatic access to a user's calendar events, allowing for the creation, retrieval, update, and deletion of events within Outlook calendars. With Pipedream, you can integrate these calendar operations into workflows that automate tasks involving scheduling, event management, and coordination with other services. Whether it's triggering actions when new events are created, syncing calendar events with other scheduling tools, or managing attendees, Pipedream's serverless platform enables you to build custom automations with minimal overhead.
4
+
5
+ # Example Use Cases
6
+
7
+ - **Automated Event Reminder Emails**: Trigger a Pipedream workflow whenever a new event is added to an Outlook Calendar. The workflow could send a reminder email via a service like SendGrid or Gmail to all the attendees a day before the event occurs, ensuring everyone is prepped and on time.
8
+
9
+ - **Cross-Platform Calendar Sync**: Sync events between Microsoft Outlook Calendar and Google Calendar. When an event is created or updated in Outlook, a Pipedream workflow can create or update a corresponding event in Google Calendar. This ensures that users who operate across different platforms have unified schedules.
10
+
11
+ - **Meeting Room Availability Checker**: Monitor your Outlook Calendar for new meetings and automatically check the availability of meeting rooms using a service like Google's G Suite Admin SDK. If a room is available, the workflow reserves it and updates the event with the room's details. If not, it could notify the organizer to select a different room or time.
@@ -0,0 +1,111 @@
1
+ import microsoftOutlook from "../../microsoft_outlook_calendar.app.mjs";
2
+
3
+ export default {
4
+ type: "action",
5
+ key: "microsoft_outlook_calendar-create-calendar-event",
6
+ version: "0.0.6",
7
+ name: "Create Calendar Event",
8
+ description: "Create an event in the user's default calendar. [See the documentation](https://docs.microsoft.com/en-us/graph/api/user-post-events)",
9
+ props: {
10
+ microsoftOutlook,
11
+ subject: {
12
+ label: "Subject",
13
+ description: "Subject of the event",
14
+ type: "string",
15
+ },
16
+ contentType: {
17
+ propDefinition: [
18
+ microsoftOutlook,
19
+ "contentType",
20
+ ],
21
+ },
22
+ content: {
23
+ propDefinition: [
24
+ microsoftOutlook,
25
+ "content",
26
+ ],
27
+ description: "Content",
28
+ },
29
+ timeZone: {
30
+ propDefinition: [
31
+ microsoftOutlook,
32
+ "timeZone",
33
+ ],
34
+ },
35
+ start: {
36
+ propDefinition: [
37
+ microsoftOutlook,
38
+ "start",
39
+ ],
40
+ },
41
+ end: {
42
+ propDefinition: [
43
+ microsoftOutlook,
44
+ "end",
45
+ ],
46
+ },
47
+ attendees: {
48
+ propDefinition: [
49
+ microsoftOutlook,
50
+ "attendees",
51
+ ],
52
+ },
53
+ location: {
54
+ propDefinition: [
55
+ microsoftOutlook,
56
+ "location",
57
+ ],
58
+ },
59
+ isOnlineMeeting: {
60
+ propDefinition: [
61
+ microsoftOutlook,
62
+ "isOnlineMeeting",
63
+ ],
64
+ },
65
+ expand: {
66
+ propDefinition: [
67
+ microsoftOutlook,
68
+ "expand",
69
+ ],
70
+ description: "Additional event details, [See object definition](https://docs.microsoft.com/en-us/graph/api/resources/event)",
71
+ },
72
+ },
73
+ async run({ $ }) {
74
+ //RegExp to check time strings(yyyy-MM-ddThh:mm:ss)
75
+ const re = /^(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)$/;
76
+ if (!re.test(this.start) || !re.test(this.start)) {
77
+ throw new Error("Please provide both start and end props in 'yyyy-MM-ddThh:mm:ss'");
78
+ }
79
+ const data = {
80
+ subject: this.subject,
81
+ body: {
82
+ contentType: this.contentType ?? "HTML",
83
+ content: this.content,
84
+ },
85
+ start: {
86
+ dateTime: this.start,
87
+ timeZone: this.timeZone,
88
+ },
89
+ end: {
90
+ dateTime: this.end,
91
+ timeZone: this.timeZone,
92
+ },
93
+ location: {
94
+ displayName: this.location,
95
+ },
96
+ attendees: this.attendees.map((at) => ({
97
+ emailAddress: {
98
+ address: at,
99
+ },
100
+ })),
101
+ isOnlineMeeting: this.isOnlineMeeting,
102
+ ...this.expand,
103
+ };
104
+ const response = await this.microsoftOutlook.createCalendarEvent({
105
+ $,
106
+ data,
107
+ });
108
+ $.export("$summary", "Calendar event has been created.");
109
+ return response;
110
+ },
111
+ };
@@ -0,0 +1,28 @@
1
+ import microsoftOutlook from "../../microsoft_outlook_calendar.app.mjs";
2
+
3
+ export default {
4
+ type: "action",
5
+ key: "microsoft_outlook_calendar-delete-calendar-event",
6
+ version: "0.0.1",
7
+ name: "Delete Calendar Event",
8
+ description: "Delete an event in the user's default calendar. [See the documentation](https://learn.microsoft.com/en-us/graph/api/event-delete?view=graph-rest-1.0&tabs=http)",
9
+ props: {
10
+ microsoftOutlook,
11
+ eventId: {
12
+ propDefinition: [
13
+ microsoftOutlook,
14
+ "eventId",
15
+ ],
16
+ },
17
+ },
18
+ async run({ $ }) {
19
+ const response = await this.microsoftOutlook.deleteCalendarEvent({
20
+ $,
21
+ eventId: this.eventId,
22
+ });
23
+
24
+ $.export("$summary", `Successfully deleted calendar event with ID ${this.eventId}`);
25
+
26
+ return response;
27
+ },
28
+ };
@@ -0,0 +1,71 @@
1
+ import microsoftOutlook from "../../microsoft_outlook_calendar.app.mjs";
2
+
3
+ export default {
4
+ key: "microsoft_outlook_calendar-get-schedule",
5
+ name: "Get Free/Busy Schedule",
6
+ description: "Get the free/busy availability information for a collection of users, distributions lists, or resources (rooms or equipment) for a specified time period. [See the documentation](https://learn.microsoft.com/en-us/graph/api/calendar-getschedule)",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ props: {
10
+ microsoftOutlook,
11
+ schedules: {
12
+ type: "string[]",
13
+ label: "Schedules",
14
+ description: "A collection of SMTP addresses of users, distribution lists, or resources to get availability information for",
15
+ },
16
+ start: {
17
+ propDefinition: [
18
+ microsoftOutlook,
19
+ "start",
20
+ ],
21
+ },
22
+ end: {
23
+ propDefinition: [
24
+ microsoftOutlook,
25
+ "end",
26
+ ],
27
+ },
28
+ timeZone: {
29
+ propDefinition: [
30
+ microsoftOutlook,
31
+ "timeZone",
32
+ ],
33
+ },
34
+ availabilityViewInterval: {
35
+ type: "integer",
36
+ label: "Availability View Interval",
37
+ description: "Represents the duration of a time slot in minutes in an availabilityView in the response. The default is 30 minutes, minimum is 5, maximum is 1440.",
38
+ optional: true,
39
+ },
40
+ },
41
+ methods: {
42
+ getSchedule(opts = {}) {
43
+ return this.microsoftOutlook._makeRequest({
44
+ method: "POST",
45
+ path: "/me/calendar/getSchedule",
46
+ ...opts,
47
+ });
48
+ },
49
+ },
50
+ async run({ $ }) {
51
+ const { value } = await this.getSchedule({
52
+ $,
53
+ data: {
54
+ schedules: this.schedules,
55
+ startTime: {
56
+ dateTime: this.start,
57
+ timeZone: this.timeZone,
58
+ },
59
+ endTime: {
60
+ dateTime: this.end,
61
+ timeZone: this.timeZone,
62
+ },
63
+ availabilityViewInterval: this.availabilityViewInterval,
64
+ },
65
+ });
66
+
67
+ $.export("$summary", `Successfully retrieved schedules for \`${this.schedules.join("`, `")}\``);
68
+
69
+ return value;
70
+ },
71
+ };
@@ -0,0 +1,64 @@
1
+ import microsoftOutlook from "../../microsoft_outlook_calendar.app.mjs";
2
+
3
+ export default {
4
+ key: "microsoft_outlook_calendar-list-events",
5
+ name: "List Events",
6
+ description: "Get a list of event objects in the user's mailbox. [See the documentation](https://learn.microsoft.com/en-us/graph/api/user-list-events)",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ props: {
10
+ microsoftOutlook,
11
+ filter: {
12
+ type: "string",
13
+ label: "Filter",
14
+ description: "Use the `$filter` query parameter to filter events. E.g. `contains(subject, 'my event')` [See the documentation](https://learn.microsoft.com/en-us/graph/filter-query-parameter) for more information about the `$filter` parameter.",
15
+ optional: true,
16
+ },
17
+ orderBy: {
18
+ type: "string",
19
+ label: "Order By",
20
+ description: "The field to sort the results by. Default is `createdDateTime`. [See the documentation](https://learn.microsoft.com/en-us/graph/query-parameters?tabs=http#orderby-parameter) for more info about the `$orderby` parameter.",
21
+ default: "createdDateTime",
22
+ optional: true,
23
+ },
24
+ sortOrder: {
25
+ type: "string",
26
+ label: "Sort Order",
27
+ description: "Whether to sort the results in ascending or descending order. Default is `descending`.",
28
+ options: [
29
+ {
30
+ label: "ascending",
31
+ value: "asc",
32
+ },
33
+ {
34
+ label: "descending",
35
+ value: "desc",
36
+ },
37
+ ],
38
+ default: "desc",
39
+ optional: true,
40
+ },
41
+ maxResults: {
42
+ type: "integer",
43
+ label: "Max Results",
44
+ description: "The maximum number of results to return",
45
+ optional: true,
46
+ },
47
+ },
48
+ async run({ $ }) {
49
+ const { value = [] } = await this.microsoftOutlook.listCalendarEvents({
50
+ $,
51
+ params: {
52
+ "$orderby": `${this.orderBy} ${this.sortOrder}`,
53
+ "$filter": this.filter,
54
+ "$top": this.maxResults,
55
+ },
56
+ });
57
+
58
+ $.export("$summary", `Successfully retrieved ${value.length} event${value.length === 1
59
+ ? ""
60
+ : "s"}`);
61
+
62
+ return value;
63
+ },
64
+ };
@@ -0,0 +1,142 @@
1
+ import microsoftOutlook from "../../microsoft_outlook_calendar.app.mjs";
2
+
3
+ export default {
4
+ type: "action",
5
+ key: "microsoft_outlook_calendar-update-calendar-event",
6
+ version: "0.0.1",
7
+ name: "Update Calendar Event",
8
+ description: "Update an event in the user's default calendar. [See the documentation](https://learn.microsoft.com/en-us/graph/api/event-update?view=graph-rest-1.0&tabs=http)",
9
+ props: {
10
+ microsoftOutlook,
11
+ eventId: {
12
+ propDefinition: [
13
+ microsoftOutlook,
14
+ "eventId",
15
+ ],
16
+ },
17
+ subject: {
18
+ label: "Subject",
19
+ description: "Subject of the event",
20
+ type: "string",
21
+ optional: true,
22
+
23
+ },
24
+ contentType: {
25
+ propDefinition: [
26
+ microsoftOutlook,
27
+ "contentType",
28
+ ],
29
+ optional: true,
30
+ },
31
+ content: {
32
+ propDefinition: [
33
+ microsoftOutlook,
34
+ "content",
35
+ ],
36
+ description: "Content",
37
+ optional: true,
38
+ },
39
+ timeZone: {
40
+ propDefinition: [
41
+ microsoftOutlook,
42
+ "timeZone",
43
+ ],
44
+ optional: true,
45
+ },
46
+ start: {
47
+ propDefinition: [
48
+ microsoftOutlook,
49
+ "start",
50
+ ],
51
+ optional: true,
52
+ },
53
+ end: {
54
+ propDefinition: [
55
+ microsoftOutlook,
56
+ "end",
57
+ ],
58
+ optional: true,
59
+ },
60
+ attendees: {
61
+ propDefinition: [
62
+ microsoftOutlook,
63
+ "attendees",
64
+ ],
65
+ optional: true,
66
+ },
67
+ location: {
68
+ propDefinition: [
69
+ microsoftOutlook,
70
+ "location",
71
+ ],
72
+ optional: true,
73
+ },
74
+ isOnlineMeeting: {
75
+ propDefinition: [
76
+ microsoftOutlook,
77
+ "isOnlineMeeting",
78
+ ],
79
+ optional: true,
80
+ },
81
+ expand: {
82
+ propDefinition: [
83
+ microsoftOutlook,
84
+ "expand",
85
+ ],
86
+ description: "Additional event details, [See object definition](https://docs.microsoft.com/en-us/graph/api/resources/event)",
87
+ optional: true,
88
+ },
89
+ },
90
+ async run({ $ }) {
91
+ const data = {
92
+ subject: this.subject,
93
+ isOnlineMeeting: this.isOnlineMeeting,
94
+ ...this.expand,
95
+ };
96
+
97
+ if (this.location) {
98
+ data.location = {
99
+ displayName: this.location,
100
+ };
101
+ }
102
+
103
+ if (this.contentType && this.content) {
104
+ data.body = {
105
+ contentType: this.contentType ?? "HTML",
106
+ content: this.content,
107
+ };
108
+ }
109
+
110
+ if (this.start && this.timeZone) {
111
+ data.start = {
112
+ dateTime: this.start,
113
+ timeZone: this.timeZone,
114
+
115
+ };
116
+ }
117
+ if (this.end && this.timeZone) {
118
+ data.end = {
119
+ dateTime: this.end,
120
+ timeZone: this.timeZone,
121
+ };
122
+ }
123
+
124
+ if (this.attendees) {
125
+ data.attendees = this.attendees.map((at) => ({
126
+ emailAddress: {
127
+ address: at,
128
+ },
129
+ }));
130
+ }
131
+
132
+ const response = await this.microsoftOutlook.updateCalendarEvent({
133
+ $,
134
+ eventId: this.eventId,
135
+ data,
136
+ });
137
+
138
+ $.export("$summary", `Successfully updated calendar event with ID ${response.id}`);
139
+
140
+ return response;
141
+ },
142
+ };
@@ -4,6 +4,19 @@ export default {
4
4
  type: "app",
5
5
  app: "microsoft_outlook_calendar",
6
6
  propDefinitions: {
7
+ eventId: {
8
+ label: "Event ID",
9
+ description: "The event ID",
10
+ type: "string",
11
+ async options() {
12
+ const { value: events } = await this.listCalendarEvents();
13
+
14
+ return events.map((event) => ({
15
+ label: event.subject,
16
+ value: event.id,
17
+ }));
18
+ },
19
+ },
7
20
  contentType: {
8
21
  label: "Content Type",
9
22
  description: "Content type (default `text`)",
@@ -132,6 +145,24 @@ export default {
132
145
  ...args,
133
146
  });
134
147
  },
148
+ async updateCalendarEvent({
149
+ eventId, ...args
150
+ }) {
151
+ return this._makeRequest({
152
+ method: "PATCH",
153
+ path: `/me/events/${eventId}`,
154
+ ...args,
155
+ });
156
+ },
157
+ async deleteCalendarEvent({
158
+ eventId, ...args
159
+ }) {
160
+ return this._makeRequest({
161
+ method: "DELETE",
162
+ path: `/me/events/${eventId}`,
163
+ ...args,
164
+ });
165
+ },
135
166
  async listCalendarEvents(args = {}) {
136
167
  return this._makeRequest({
137
168
  method: "GET",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/microsoft_outlook_calendar",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Pipedream Microsoft Outlook Calendar Components",
5
5
  "main": "microsoft_outlook_calendar.app.mjs",
6
6
  "keywords": [
@@ -11,10 +11,10 @@
11
11
  ],
12
12
  "homepage": "https://pipedream.com/apps/microsoft_outlook_calendar",
13
13
  "author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
14
- "dependencies": {
15
- "@pipedream/platform": "^1.5.1"
16
- },
17
14
  "publishConfig": {
18
15
  "access": "public"
16
+ },
17
+ "dependencies": {
18
+ "@pipedream/platform": "^3.0.3"
19
19
  }
20
20
  }
@@ -0,0 +1,10 @@
1
+ import microsoftOutlook from "../microsoft_outlook_calendar.app.mjs";
2
+ import common from "../../microsoft_outlook/sources/common.mjs";
3
+
4
+ export default {
5
+ ...common,
6
+ props: {
7
+ ...common.props,
8
+ microsoftOutlook,
9
+ },
10
+ };
@@ -0,0 +1,56 @@
1
+ import common from "../common.mjs";
2
+
3
+ export default {
4
+ ...common,
5
+ key: "microsoft_outlook_calendar-new-calendar-event",
6
+ name: "New Calendar Event (Instant)",
7
+ description: "Emit new event when a new Calendar event is created",
8
+ version: "0.0.7",
9
+ type: "source",
10
+ hooks: {
11
+ ...common.hooks,
12
+ async activate() {
13
+ await this.activate({
14
+ changeType: "created",
15
+ resource: "/me/events",
16
+ });
17
+ },
18
+ async deactivate() {
19
+ await this.deactivate();
20
+ },
21
+ },
22
+ methods: {
23
+ ...common.methods,
24
+ async getSampleEvents({ pageSize }) {
25
+ return this.microsoftOutlook.listCalendarEvents({
26
+ params: {
27
+ $top: pageSize,
28
+ $orderby: "createdDateTime desc",
29
+ },
30
+ });
31
+ },
32
+ emitEvent(item) {
33
+ this.$emit({
34
+ message: item,
35
+ }, this.generateMeta(item));
36
+ },
37
+ generateMeta(item) {
38
+ return {
39
+ id: item.id,
40
+ summary: `New calendar event (ID:${item.id})`,
41
+ ts: Date.parse(item.createdDateTime),
42
+ };
43
+ },
44
+ },
45
+ async run(event) {
46
+ await this.run({
47
+ event,
48
+ emitFn: async ({ resourceId } = {}) => {
49
+ const item = await this.microsoftOutlook.getCalendarEvent({
50
+ eventId: resourceId,
51
+ });
52
+ this.emitEvent(item);
53
+ },
54
+ });
55
+ },
56
+ };
@@ -0,0 +1,92 @@
1
+ import common from "../common.mjs";
2
+ import taskScheduler from "../../../pipedream/sources/new-scheduled-tasks/new-scheduled-tasks.mjs";
3
+
4
+ export default {
5
+ ...common,
6
+ key: "microsoft_outlook_calendar-new-upcoming-event",
7
+ name: "New Upcoming Calendar Event",
8
+ description: "Emit new event when a Calendar event is upcoming, this source is using `reminderMinutesBeforeStart` property of the event to determine the time it should emit.",
9
+ version: "0.0.3",
10
+ type: "source",
11
+ props: {
12
+ ...common.props,
13
+ pipedream: taskScheduler.props.pipedream,
14
+ },
15
+ hooks: {
16
+ ...common.hooks,
17
+ async activate() {
18
+ await this.activate({
19
+ changeType: "updated",
20
+ resource: "/me/events",
21
+ });
22
+ },
23
+ async deactivate() {
24
+ await this.deactivate();
25
+ },
26
+ },
27
+ methods: {
28
+ ...taskScheduler.methods,
29
+ ...common.methods,
30
+ _hasDeployed() {
31
+ const result = this.db.get("hasDeployed");
32
+ this.db.set("hasDeployed", true);
33
+ return result;
34
+ },
35
+ subtractMinutes(date, minutes) {
36
+ return date.getTime() - minutes * 60000;
37
+ },
38
+ async getSampleEvents({ pageSize }) {
39
+ return this.microsoftOutlook.listCalendarEvents({
40
+ params: {
41
+ $top: pageSize,
42
+ $orderby: "lastModifiedDateTime desc",
43
+ },
44
+ });
45
+ },
46
+ emitEvent(item) {
47
+ this.$emit({
48
+ message: item,
49
+ }, this.generateMeta(item));
50
+ },
51
+ generateMeta(item) {
52
+ return {
53
+ id: item.id,
54
+ summary: `Upcoming event - ${item.subject}`,
55
+ ts: +Date.parse(item.createdDateTime),
56
+ };
57
+ },
58
+ },
59
+ async run(event) {
60
+ if (event.$channel === this.selfChannel()) {
61
+ const item = await this.microsoftOutlook.getCalendarEvent({
62
+ eventId: event.eventId,
63
+ });
64
+ // checking if the event was modified after this scheduling
65
+ if (item.lastModifiedDateTime === event.lastModifiedControl) {
66
+ this.emitEvent(item);
67
+ }
68
+ return;
69
+ }
70
+ await this.run({
71
+ event,
72
+ emitFn: async ({ resourceId } = {}) => {
73
+ if (!this._hasDeployed()) {
74
+ await this.selfSubscribe();
75
+ }
76
+ const item = await this.microsoftOutlook.getCalendarEvent({
77
+ eventId: resourceId,
78
+ });
79
+ if (event.$channel !== this.selfChannel()) {
80
+ const startTime = new Date(item.start.dateTime || item.start.date);
81
+ const reminderMinutesBeforeStart = item.reminderMinutesBeforeStart || 15;
82
+ const later = new Date(this.subtractMinutes(startTime, reminderMinutesBeforeStart));
83
+ const newEvent = {
84
+ lastModifiedControl: item.lastModifiedDateTime,
85
+ eventId: resourceId,
86
+ };
87
+ this.emitScheduleEvent(newEvent, later);
88
+ }
89
+ },
90
+ });
91
+ },
92
+ };
@@ -0,0 +1,56 @@
1
+ import common from "../common.mjs";
2
+
3
+ export default {
4
+ ...common,
5
+ key: "microsoft_outlook_calendar-updated-calendar-event",
6
+ name: "New Calendar Event Update (Instant)",
7
+ description: "Emit new event when a Calendar event is updated",
8
+ version: "0.0.7",
9
+ type: "source",
10
+ hooks: {
11
+ ...common.hooks,
12
+ async activate() {
13
+ await this.activate({
14
+ changeType: "updated",
15
+ resource: "/me/events",
16
+ });
17
+ },
18
+ async deactivate() {
19
+ await this.deactivate();
20
+ },
21
+ },
22
+ methods: {
23
+ ...common.methods,
24
+ async getSampleEvents({ pageSize }) {
25
+ return this.microsoftOutlook.listCalendarEvents({
26
+ params: {
27
+ $top: pageSize,
28
+ $orderby: "lastModifiedDateTime desc",
29
+ },
30
+ });
31
+ },
32
+ emitEvent(item) {
33
+ this.$emit({
34
+ message: item,
35
+ }, this.generateMeta(item));
36
+ },
37
+ generateMeta(item) {
38
+ return {
39
+ id: item.id,
40
+ summary: `Calendar event updated (ID:${item.id})`,
41
+ ts: Date.parse(item.createdDateTime),
42
+ };
43
+ },
44
+ },
45
+ async run(event) {
46
+ await this.run({
47
+ event,
48
+ emitFn: async ({ resourceId } = {}) => {
49
+ const item = await this.microsoftOutlook.getCalendarEvent({
50
+ eventId: resourceId,
51
+ });
52
+ this.emitEvent(item);
53
+ },
54
+ });
55
+ },
56
+ };