/* * 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 a party that a webhook is for */ type WebhookVxtParty = { /** A webhook for a team member's message (this includes messages from direct phone numbers) */ type: 'user', uid: string, email: string, } | { /** A webhook for a message in a shared phone number */ type: 'sharedPhoneNumber', phoneNumberE164: string, } /** Describes a party, other than the party the webhook is for, 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: 2, /** 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 party whose call log this webhook is for. */ direction: 'inbound' | 'outbound', /** The party whose call log this webhook is for. */ party: WebhookVxtParty, /** 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: 2, /** 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 party whose voicemail this webhook is for. */ party: WebhookVxtParty, /** The party that left the voicemail. */ callerId: WebhookOtherParty, }