/* * VXT webhook payloads will conform to the WebhookPayload type defined here in TypeScript. * Webhooks will be delivered in JSON format with the header "Authorization: Bearer {token}". * New fields or event types may be added in the future. Note that our agent will not follow redirects. */ type WebhookPayload = { event: 'callLog', callLog: CallLogWebhookPayload, } | { event: 'voicemail', voicemail: VoicemailWebhookPayload, } /** Describes the primary VXT user in a call. */ type WebhookUser = { type: "user"; uid: string; email: string; }; /** Describes a party, other than the primary VXT user or phone number, in a call. */ type WebhookOtherParty = | { /** * Another VXT user (a teammate) in the call. Since webhooks do not deliver internal user-to-user messages, * this other party type will only be encountered in a conference call that involves both internal and external parties. */ type: "user"; uid: string; email: string; } | { /** An other party represented by a phone number. */ type: "phoneNumber"; phoneNumberE164: string; } | { /** An other party with a private caller ID. */ type: "unknown"; } | { /** * An other party not represented by a phone number, i.e. an SMS alphanumeric sender ID. * This other party type would not currently be encountered, but is specified for forward-compatibility * as SMS webhooks may be added in the future. */ type: "other"; value: string; }; type CallLogWebhookPayload = { version: 3; /** ID of the VXT message this webhook is for. */ id: string; /** * A URL to open the call log in the VXT web app, accessible to users in the same VXT team. * This also allows access to any call recording and/or transcription. */ url: string; /** The result of the call, with corresponding Unix millisecond timestamps. */ result: | { type: "missed"; startTimestamp: number; } | { type: "answered"; startTimestamp: number; answerTimestamp: number; hangupTimestamp: number; }; /** The direction of the call from the perspective of the VXT user or phone number. */ direction: "inbound" | "outbound"; /** The VXT user that placed the call, answered the call, or was targeted by a call flow * voicemail node, or otherwise null. */ user: WebhookUser | null; /** * The VXT phone number that placed/received the call, or null for a call that started as a * user-to-user call and then had external phone number(s) added to the call. */ phoneNumberE164: string | null; /** Other parties (user or external phone number) involved in the call. More than 1 means it was a conference call. */ otherParties: WebhookOtherParty[]; }; type VoicemailWebhookPayload = { version: 3; /** ID of the VXT message this webhook is for. */ id: string; /** * A URL to open the voicemail in the VXT web app, accessible to users in the same VXT team. * This also allows access to the voicemail recording and transcription. */ url: string; /** When the voicemail was left, as a Unix millisecond timestamp. */ timestamp: number; /** The duration of the voicemail audio, in milliseconds. */ duration: number; /** The transcription of the voicemail, if available. */ transcription: string | null; /** The VXT user that was targeted by a call flow voicemail node, or otherwise null. */ user: WebhookUser | null; /** The VXT phone number that received the call. */ phoneNumberE164: string | null; /** The party that left the voicemail. */ callerId: WebhookOtherParty; };