javascriptnode.jsexpressngrokcalendly

Calendly Webhooks not working in node.js and ngrok?


This is my first time posting in Stack Overflow so please pardon me if there are any issues with my question.

I am trying out Calendly Teams version and using the Webhooks feature on a Node.js web application. Here is the code:

user.js

app.post('/calendly-webhook', (req, res) => UserController.registerCalendlyWebhook(req, res))

app.post('/calendly', (req, res) => UserController.rescheduleCalendlyTest(req, res))

I am exposing two endpoints. The /calendly-webhook for registering a webhook and the /calendly is for receiving data from Calendly

controller.js

async registerCalendlyWebhook(req, res) {
        try {
            console.log('test')
            const calendly = new CalendlyService();
            const currentCalendly = await calendly.getCurrent()
            const webhookParams = {
                url: "https://de46-2001-4455-6c9-2800-850c-710e-73a-e978.ap.ngrok.io/calendly",
                events: [
                    "invitee.created",
                    "invitee.canceled"
                ],
                organization: currentCalendly.resource.current_organization,
                user: currentCalendly.resource.uri,
                scope: "user",
                signing_key: "FoNCQVQESdyQX_g8QZN0ZTSDb_FCEPAU-fJMc86mgBw"
            }
            console.log('CURRENT: ', currentCalendly.resource)
            const webhook = await calendly.createWebhookSubscription(webhookParams)
            console.log('WEBHOOK: ', webhook)
            return res.status(httpStatus.OK).send({ message: 'Webhooks accepted successfully' })
        } catch (error) {
            console.log(error)
        }
    }

    /**
   * Calendly test
   * @param {*} req 
   * @param {*} res 
   */
    async rescheduleCalendlyTest(req, res) {
        console.log('****************************************************************')
        console.log('It Works!!!!'
        console.log('****************************************************************')
        
    }

I was able to successfully create a webhook subscription. The main issue here is that, When I try to create a new event or reschedule a new one, I'm not receiving any response from Calendly. Is there something that I may have missed? Funny thing is, It was working a few weeks from now and it also works when I use RequestBin instead of Ngrok.

What I tried I tried resetting my Ngrok address multiple times, Turned off windows firewall and antivirus, Created a new app in calendly developer, Recreated tokens and followed the documentation

Expected Output After successfully creating a webhook subscription, I should be receiving a response from calendly webhooks in the /calendly endpoint when I schedule a new event or reschedule an existing event. As a start, the console.log() statements should work properly

What Happened The console.log() statements are not being triggered. I tried inspecting using Ngrok and im not seeing any response from calendly


Solution

  • I was able to solve the issue by creating an account in Ngrok and have my authtoken installed.