cal.com icon indicating copy to clipboard operation
cal.com copied to clipboard

[CAL-4491] [V2 Admin API] Add Missing Functionality to the Org Create Event Type Endpoint

Open SteveKekacs opened this issue 1 year ago • 3 comments

Is your proposal related to a problem?

The v2 admin api org create event type endpoint is missing a few pieces of functionality:

  • For booking fields, the ability to set field to disable the input if the URL identifier is prefilled.
  • Ability to configure a recurring event.
  • Ability to configure seats for an event.
  • Ability to override the default booking fields (to change the display name for the name and email fields).

Describe the solution you'd like

  • In the bookingFields array of objects, add a disableIfPrefilled: boolean or similar field.
  • Add a new top level recurringConfig?: { maxEvents: number, repeatConfig: { value: number, repeatInterval: "week" | "month" | "year"} } (or similar) field.
  • Add a new top level seatsConfig?: { numSeats: number, shareAttendeeInfo: boolean, showNumberOfAvailableSeats: boolean } (or similar) field.
  • Allow overriding the default booking fields.

Describe alternatives you've considered

Right now we're having to create events via the api, then go to the UI to configure these fields. We're creating many different event types for our use case, so this is a time consuming process.

Additional context

N/A

Requirement/Document

N/A


House rules
  • If this issue has a 🚨 needs approval label, don't start coding yet. Wait until a core member approves feature request by removing this label, then you can start coding.
    • For clarity: Non-core member issues automatically get the 🚨 needs approval label.
    • Your feature ideas are invaluable to us! However, they undergo review to ensure alignment with the product's direction.
    • Follow Best Practices lined out in our Contributor Docs

CAL-4491

SteveKekacs avatar Oct 04 '24 13:10 SteveKekacs

cc: @keithwillcode @supalarry @ThyMinimalDev Can we line it up please?

alishaz-polymath avatar Oct 07 '24 02:10 alishaz-polymath

@SteveKekacs We have this PR in review that will allow:

  1. Specifying disableOnPrefill property for each booking field.
  2. Modify label, placeholder and disableOnPrefill for the default name and email fields. I think if you click on Linear ticket linked to the task there is more context available if you are interested.

As for specifying event type recurrence and seats, it is already possible if you check api docs for event types. Specifically recurrence and seats properties.

supalarry avatar Oct 19 '24 14:10 supalarry

Great, thanks for the update @supalarry!

SteveKekacs avatar Oct 19 '24 14:10 SteveKekacs

Hey @supalarry, just got around to testing this. the disableOnPrefill is working, but it looks like overriding the default name and email fields is not.

  • It's returning a 400 BAD REQUEST (duplicate field name) error
  • Though the event is getting created, but just with messed up fields Screenshot 2024-10-23 at 2 29 01 PM

Request details

POST /v2/organizations/{ORG_ID}/teams/{TEAM_IDS}/event-types
Request Body: {
  "lengthInMinutes": 60,
  "title": "Intake",
  "slug": "testing",
  "description": "....",
  "hosts": [],
  "minimumBookingNotice": 4320,
  "slotInterval": 30,
  "locations": [
    {
      "type": "integration",
      "integration": "cal-video"
    }
  ],
  "bookingFields": [
    {
      "type": "email",
      "slug": "email",
      "label": "Student Email",
      "required": true,
      "disableOnPrefill": true
    },
    {
      "type": "text",
      "slug": "name",
      "label": "Student Name",
      "required": true,
      "disableOnPrefill": true
    },
    {
      "type": "multiemail",
      "slug": "guests",
      "label": "Guardian Emails",
      "required": false,
      "disableOnPrefill": true
    }
  ],
  "customName": "{Event type title} between {HOST} and {ATTENDEE}",
  "disableGuests": false,
  "schedulingType": "ROUND_ROBIN",
  "assignAllTeamMembers": false,
  "beforeEventBuffer": 0,
  "afterEventBuffer": 0,
  "onlyShowFirstAvailableSlot": false,
  "bookingLimitsCount": {},
  "bookingLimitsDuration": {}
}

Response Body: {
  "status": "error",
  "timestamp": "2024-10-23T18:15:30.429Z",
  "path": "/v2/organizations/16327/teams/17510/event-types",
  "error": {
    "code": "TRPCError",
    "message": "Duplicate booking field name: name"
  }
}

SteveKekacs avatar Oct 23 '24 18:10 SteveKekacs

@SteveKekacs sorry for late reply missed your issue above.

The reason for 400 is that for name and email booking fields you need to skip slug and simply denote their type. The slug for name and email are set automatically later on and is not accepted as input, because the slug is fixed. In your case you need to submit:

{
    "bookingFields": [
    {
      "type": "email",
      "label": "Student Email",
      "required": true,
      "disableOnPrefill": true
    },
    {
      "type": "name",
      "label": "Student Name",
      "required": true,
      "disableOnPrefill": true
    },
    {
      "type": "multiemail",
      "slug": "guests",
      "label": "Guardian Emails",
      "required": false,
      "disableOnPrefill": true
    }
  ]
}

I confirm that with booking fields above it is a successful request.

supalarry avatar Nov 14 '24 10:11 supalarry

@supalarry ah makes sense, thank you!

SteveKekacs avatar Nov 14 '24 17:11 SteveKekacs

Hi @supalarry,

I'm still having issues with this. When I don't include the slug for name & email fields, I'm getting a 400 response on creating a new event:

Request:
{
  ...,
  "bookingFields": [
    {
      "type": "email",
      "label": "Student Email",
      "required": true,
      "disableOnPrefill": true
    },
    {
      "type": "text",
      "label": "Student Name",
      "required": true,
      "disableOnPrefill": true
    }
  ]
}


Response
{
  "status": "error",
  "timestamp": "2024-11-21T12:58:17.853Z",
  "path": "/v2/organizations/16327/teams/17510/event-types",
  "error": {
    "code": "BadRequestException",
    "message": "Each booking field must have a 'slug' property.",
    "details": {
      "message": "Each booking field must have a 'slug' property.",
      "error": "Bad Request",
      "statusCode": 400
    }
  }
}

SteveKekacs avatar Nov 21 '24 13:11 SteveKekacs

Hi @supalarry,

I'm still having issues with this. When I don't include the slug for name & email fields, I'm getting a 400 response on creating a new event:

Request:
{
  ...,
  "bookingFields": [
    {
      "type": "email",
      "label": "Student Email",
      "required": true,
      "disableOnPrefill": true
    },
    {
      "type": "text",
      "label": "Student Name",
      "required": true,
      "disableOnPrefill": true
    }
  ]
}


Response
{
  "status": "error",
  "timestamp": "2024-11-21T12:58:17.853Z",
  "path": "/v2/organizations/16327/teams/17510/event-types",
  "error": {
    "code": "BadRequestException",
    "message": "Each booking field must have a 'slug' property.",
    "details": {
      "message": "Each booking field must have a 'slug' property.",
      "error": "Bad Request",
      "statusCode": 400
    }
  }
}

Booking fields of type name and email don't need a slug, but all other ones do. In the code above we have type text but it has a missing slug. If you try with the following it should work:

...
   {
      "type": "text",
      "slug": "student-name",
      "label": "Student Name",
      "required": true,
      "disableOnPrefill": true
    }
...

supalarry avatar Nov 22 '24 12:11 supalarry

@supalarry ah I apologize 🤦‍♂️ missed that the name field type needs to be "name" not "text".

SteveKekacs avatar Nov 22 '24 13:11 SteveKekacs

@supalarry ah I apologize 🤦‍♂️ missed that the name field type needs to be "name" not "text".

All good, glad to hear it's working! : )

supalarry avatar Nov 22 '24 13:11 supalarry