11import calCom from "../../cal_com.app.mjs" ;
2+ import { ConfigurationError } from "@pipedream/platform" ;
23
34export default {
45 key : "cal_com-create-booking" ,
56 name : "Create Booking" ,
6- description : "Create a new booking. [See the docs here ](https://developer.cal.com/api/api-reference/bookings#create-a-new-booking)" ,
7- version : "0.0.1 " ,
7+ description : "Create a new booking. [See the documentation ](https://developer.cal.com/api/api-reference/bookings#create-a-new-booking)" ,
8+ version : "0.0.2 " ,
89 type : "action" ,
910 props : {
1011 calCom,
11- eventType : {
12+ eventTypeId : {
1213 propDefinition : [
1314 calCom ,
14- "eventType " ,
15+ "eventTypeId " ,
1516 ] ,
1617 } ,
1718 name : {
@@ -33,12 +34,12 @@ export default {
3334 startTime : {
3435 type : "string" ,
3536 label : "Start Time" ,
36- description : "The start time of the new booking in **ISO 8601** format" ,
37+ description : "The start time of the new booking in **ISO 8601** format. E.g. `2025-04-21T20:28:00` " ,
3738 } ,
3839 endTime : {
3940 type : "string" ,
4041 label : "End Time" ,
41- description : "The end time of the new booking in **ISO 8601** format" ,
42+ description : "The end time of the new booking in **ISO 8601** format. E.g. `2025-04-21T20:28:00` " ,
4243 } ,
4344 recurringCount : {
4445 type : "integer" ,
@@ -61,7 +62,7 @@ export default {
6162 } ,
6263 async run ( { $ } ) {
6364 const data = {
64- eventTypeId : this . eventType ,
65+ eventTypeId : this . eventTypeId ,
6566 name : this . name ,
6667 email : this . email ,
6768 title : this . title ,
@@ -74,11 +75,19 @@ export default {
7475 customInputs : [ ] ,
7576 metadata : { } ,
7677 } ;
77- const response = await this . calCom . createBooking ( {
78- data,
79- $,
80- } ) ;
81- $ . export ( "$summary" , `Successfully created booking with ID ${ response . id } ` ) ;
82- return response ;
78+ try {
79+ const response = await this . calCom . createBooking ( {
80+ data,
81+ $,
82+ } ) ;
83+ $ . export ( "$summary" , `Successfully created booking with ID ${ response . id } ` ) ;
84+ return response ;
85+ } catch ( error ) {
86+ const errorJson = JSON . parse ( error . slice ( error . indexOf ( "{" ) ) ) ;
87+ const message = errorJson ?. data ?. message ;
88+ throw new ConfigurationError ( `Error: ${ message } ${ message === "no_available_users_found_error"
89+ ? ". No users are available to be assigned to a booking at the specified time"
90+ : "" } `) ;
91+ }
8392 } ,
8493} ;
0 commit comments