vonage-node-sdk icon indicating copy to clipboard operation
vonage-node-sdk copied to clipboard

How Do I: Type the Webhook events I receive from Vonage

Open BeLi4L opened this issue 9 months ago • 1 comments

How do I

type the webhook events I receive from Vonage

API/Product

Accounts

Code Sample

Context

I'm working on integrating "Silent Auth" into our product, and I'm writing an HTTP endpoint to receive Vonage webhook events. I need to know the types of the events I can receive.

Problem

I see there's a SilentAuthCallback type but it does NOT match the reality of what we receive.

Indeed, some objects I received looked like:

{
  "request_id": "...",
  "triggered_at": "2025-02-04T14:49:47.893Z",
  "channel": "silent_auth",
  "status": "failed",
  "type": "event"
}

where "action" is missing, or:

{
  "request_id": "...",
  "submitted_at": "2025-02-04T14:49:42.000Z",
  "finalized_at": "2025-02-04T14:49:47.000Z",
  "status": "failed",
  "workflow": [
    {
      "channel": "silent_auth",
      "status": "failed",
      "initiated_at": "2025-02-04T14:49:43.332Z"
    }
  ],
  "channel_timeout": 180,
  "type": "summary"
}

which is not at all a SilentAuthCallback object.

Potential solution(s)

  • Improve typings by specifying all possible event types, e.g.
    export type SilentAuthCallback =
      | SilentAuthSucceededCallback
      | SilentAuthFailedCallback
      | SilentAuthSummaryCallback
      | SilentAuthExpiredCallback // and so on for all types of event...
    
    export type SilentAuthFailedCallback = {
      request_id: string;
      triggered_at: string;
      channel: "silent_auth";
      status: "failed";
      type: "event";
    }
    
    // ...
    
  • Also adding a union type or an enum for the "type" field

BeLi4L avatar Feb 12 '25 16:02 BeLi4L

@BeLi4L The SDK does not include types for webhook requests. The types you see are used to type how we send the requests to the API. With some of the requests, custom data cannot be easily typed, so we felt it was not necessary. However, since you're requesting webhook types, we can look into adding them. I'll leave this open so I can give you updates

manchuck avatar Feb 12 '25 18:02 manchuck

@BeLi4L, I figured I would give you an update on this ticket. Come this fall, I will be working with our engineering team to get the JSON schemas for every type of request that can be sent through a webhook.

manchuck avatar Aug 19 '25 13:08 manchuck