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

Sending SMS via the API is not working.

Open StibnIT opened this issue 1 year ago • 7 comments

Issue Summary

When I book an appointment through the calendar page (GUI), I receive the SMS. However, when I send a POST request via the API, it is executed correctly, and I also receive the email confirmation, but no SMS is sent.

My json: { "eventTypeId": , "userId": , "start": "", "end": "", "responses": { "name": "name", "email": "[email protected]", "Mobilnummer": "+135463546", "notes": "", "metadata": {}, "location": "Google Meet", "smsReminderNumber": "+3423467" }, "metadata": {}, "timeZone": "Europe/Berlin", "language": "de", "title": "Termin mit ....", "description": null, "status": "PENDING" }

Steps to Reproduce

1.´testet in cal.com gui sms comes 2. Build API and send post req. sms does not come

Expected behavior

The SMS should be sent after a successful API POST request.

Other information

No response

Screenshots

No response

Environment

  • [X] app.cal.com
  • [ ] Self-hosted Cal

Desktop (please complete the following information)

- cal.com gui
- api post req. at make.com

StibnIT avatar Aug 17 '24 11:08 StibnIT

Please assign me sir

sameersuman573 avatar Aug 18 '24 06:08 sameersuman573

iisue iisue sir i am not getting the option of assigning phone number

sameersuman573 avatar Aug 18 '24 06:08 sameersuman573

Uploading Screenshot from 2024-08-18 12-35-26.png… The receipt Iteslf write that "We sent an email with a calendar invitation with the details to everyone." so there no talk about the phone number

sameersuman573 avatar Aug 18 '24 07:08 sameersuman573

Screenshot from 2024-08-18 12-35-26 check here

sameersuman573 avatar Aug 18 '24 07:08 sameersuman573

Uploading Screenshot from 2024-08-18 12-35-26.png… The receipt Iteslf write that "We sent an email with a calendar invitation with the details to everyone." so there no talk about the phone number

If you have the paid version, you have the function to create a workflow to automatically send an email with the appointment confirmation, then you get this field here:

image

That is the "smsReminderNumber" field. And if i book it from the booking page that works, but from the api not.

StibnIT avatar Aug 18 '24 07:08 StibnIT

@StibnIT , can you try the payload like this having smsReminderNumber outside responses object

New Booking example: value: { "eventTypeId": 2323232, "start": "2023-05-24T13:00:00.000Z", "end": "2023-05-24T13:30:00.000Z", "responses":{ "name": "Hello Hello", "email": "[email protected]", "metadata": {}, "location": "Calcom HQ", }, "timeZone": "Europe/London", "language": "en", "title": "Debugging between Syed Ali Shahbaz and Hello Hello", "description": null, "status": "PENDING", "smsReminderNumber": null }

vijayraghav-io avatar Aug 18 '24 10:08 vijayraghav-io

I Have This Error: Error: 400 Bad Request {"message":"custom in 'responses': {name}error_required_field; Legacy Props: smsReminderNumber. They can't be used with responses"}

@StibnIT , can you try the payload like this having smsReminderNumber outside responses object

New Booking example: value: { "eventTypeId": 2323232, "start": "2023-05-24T13:00:00.000Z", "end": "2023-05-24T13:30:00.000Z", "responses":{ "name": "Hello Hello", "email": "[email protected]", "metadata": {}, "location": "Calcom HQ", }, "timeZone": "Europe/London", "language": "en", "title": "Debugging between Syed Ali Shahbaz and Hello Hello", "description": null, "status": "PENDING", "smsReminderNumber": null }

StibnIT avatar Aug 18 '24 10:08 StibnIT

{ "eventTypeId": , "userId": , "start": "", "end": "", "responses": { "name": "name", "email": "[email protected]", "Mobilnummer": "+135463546", "notes": "", "metadata": {}, "location": "Google Meet", "smsReminderNumber": "+3423467" }, "metadata": {}, "timeZone": "Europe/Berlin", "language": "de", "title": "Termin mit ....", "description": null, "status": "PENDING" }

This is working now. As shown here, smsReminderNumber needs to be inside responses

CarinaWolli avatar Sep 04 '24 14:09 CarinaWolli

This is still not working for me. supplying smsReminderNumber in the API does not send any sms to the user.

Example response for successful booking:

[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] }

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: `[email protected]`,
            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)
}

govindrai avatar Oct 14 '24 06:10 govindrai

For anyone else trying to get this to work with the bookings api, you have to add an object called bookingFieldsResponses into your API request, and within that object you pass in your smsReminderNumber. The number in that specific field must have the +1 of whatever country code the number belongs to. This is how I finally got it to work for me:

`{

"start": "2025-05-29T17:00:00Z", "attendee": { "name": "John Doe", "email": "[email protected]", "phoneNumber": "5555555555", "timeZone": "America/Chicago", "language": "en" }, "eventTypeId":33333, "metadata":{}, "bookingFieldsResponses":{ "smsReminderNumber":"+15555555555" } }`

nathanmoreton avatar May 08 '25 03:05 nathanmoreton

hi, is this figured out? having trouble

benlikescrypto avatar Jul 29 '25 13:07 benlikescrypto