calcom / cal.com

Scheduling infrastructure for absolutely everyone.
https://cal.com
Other
32.57k stars 8.06k forks source link

sms reminder does not work #17090

Open govindrai opened 1 month ago

govindrai commented 1 month ago

Issue Summary

supplying smsReminderNumber in the request body does not send any sms to the user. I also see v2 api doesn't mention anything about sms reminder. Is this feature no longer supported?

Steps to Reproduce

Example code

async function bookAppointment(requestedAppointmentTime, name, phone, notes) {
    const url = new URL(`https://api.cal.com/v1/bookings`);
    url.searchParams.append("apiKey", process.env.CAL_API_KEY)

    const body = {
        eventTypeId: Number(process.env.EVENT_TYPE_ID),
        start: requestedAppointmentTime,
        responses: {
            name,
            email: `some+email@gmail.com`,
            phone,
            smsReminderNumber: phone,
            notes,
        },
        metadata: {},
        timeZone: "America/Los_Angeles",
        language: "en",
        title: "meeting title",
    }

    const response = await fetch(url, {
        headers: {
            "Content-Type": "application/json"
        },
        method: "POST",
        body: JSON.stringify(body),
    });

    if (!response.ok) {
        const error = {
            status: response.status,
            statusText: response.statusText,
            errorResponse: await response.json()
        }
        throw new Error(JSON.stringify(error, null, 2));
    }

    const data = await response.json();
    console.log(data)
}

Example response for successful booking, that does not send sms.

[dev] {
[dev]   id: 3683930,
[dev]   uid: REDACTED,
[dev]   idempotencyKey: REDACTED,
[dev]   userId: REDACTED,
[dev]   userPrimaryEmail: REDACTED,
[dev]   eventTypeId: REDACTED,
[dev]   title: "Some Title",
[dev]   description: '',
[dev]   customInputs: {},
[dev]   responses: {
[dev]     name: 'name',
[dev]     email: REDACTED,
[dev]     phone: '+1 (999) 999-9999', // changed for privacy but real number and same format used in request body 
[dev]     guests: [],
[dev]     smsReminderNumber: '+1 (999) 999-9999'
[dev]   },
[dev]   startTime: '2024-10-14T17:00:00.000Z',
[dev]   endTime: '2024-10-14T17:30:00.000Z',
[dev]   location: '123 Any Street, Anytown, CA 99999',
[dev]   createdAt: '2024-10-12T16:05:31.501Z',
[dev]   updatedAt: null,
[dev]   status: 'ACCEPTED',
[dev]   paid: false,
[dev]   destinationCalendarId: REDACTED,
[dev]   cancellationReason: null,
[dev]   rejectionReason: null,
[dev]   dynamicEventSlugRef: null,
[dev]   dynamicGroupSlugRef: null,
[dev]   rescheduled: null,
[dev]   fromReschedule: null,
[dev]   recurringEventId: null,
[dev]   smsReminderNumber: '+1 (999) 999-9999',
[dev]   scheduledJobs: [],
[dev]   metadata: {},
[dev]   isRecorded: false,
[dev]   iCalUID: REDACTED
[dev]   iCalSequence: 0,
[dev]   rating: null,
[dev]   ratingFeedback: null,
[dev]   noShowHost: false,
[dev]   oneTimePassword: null,
[dev]   cancelledBy: null,
[dev]   rescheduledBy: null,
[dev]   user: { ... },
[dev]   attendees: [
[dev]     {
[dev]       id: 4218981,
[dev]       email: REDACTED,
[dev]       name: REDACTED,
[dev]       timeZone: 'America/Los_Angeles',
[dev]       phoneNumber: null,
[dev]       locale: 'en',
[dev]       bookingId: 3683930,
[dev]       noShow: false
[dev]     }
[dev]   ],
[dev]   payment: [],
[dev]   references: [ ... ], 
[dev]   appsStatus: [ ... ],
[dev]   paymentRequired: false,
[dev]   luckyUsers: []
[dev] }

The Create Booking endpoint [API] says to supply smsReminderNumber outside of body.responses object but that returns a 400:

https://cal.com/docs/api-reference/v1/bookings/creates-a-new-booking

This other thread says to supply it in body.responses. That returns 200, but no reminder.

CarinaWolli commented 1 month ago

smsReminderNumber needs to be in responses, @alishaz-polymath we updated that before, can we fix that again?

That should work:

    "responses": {
        "name": "Hello Hello",
        "email": "c.wollendorfer@gmail.com",
        "location": "Calcom HQ",
        "smsReminderNumber": "+1 555 555 5555"
    },
CarinaWolli commented 1 month ago

Not sure about v2, @ThyMinimalDev is this missing in v2? Or just missing in the docs?

Sankalpcreat commented 1 month ago

v2 I read the docs of v2

  1. Lack of Documentation in v2
  2. Ensure that the smsReminderNumber is placed correctly in the body. While your earlier code attempts to include it, the API might expect it to be in a specific location, possibly outside of the responses object, which could lead to the feature not working as intended.
govindrai commented 1 month ago

Hey, sorry if my message was confusing. Here's a summary again. I tried both methods. Including it in the responses object doesn't send sms, but call passes with a 200. Putting it outside the responses object, as per the v1 API docs instructions, throws a 400 and error message. Basically, both methods do not work. And v2 doesn't mention sms reminders at all.

ThyMinimalDev commented 1 month ago

api-v2 does not support sms reminder yet

CarinaWolli commented 1 month ago

smsReminderNumber needs to be in responses, @alishaz-polymath we updated that before, can we fix that again?

That should work:

    "responses": {
        "name": "Hello Hello",
        "email": "c.wollendorfer@gmail.com",
        "location": "Calcom HQ",
        "smsReminderNumber": "+1 555 555 5555"
    },

I tested this and it worked for me. I received the SMS 🤔

govindrai commented 1 month ago

Hi Carina, is the format important here? For example would "+1 (555) 555-5555" not work? The docs don't state anything about number format and I'm wondering if that's where the issue stems from. I used this format: +1 (555) 555-5555 because that's the format displayed on the booking page:

image

Updating docs would be helpful.

alishaz-polymath commented 1 month ago

V1 docs are updated to show the correct usage as well, just FYI