/**
 * Instantly Reply Received Trigger Definition
 *
 * Webhook trigger for Instantly email reply events.
 * Uses Instantly's native snake_case format - no transformation needed.
 */

import type { TriggerDefinition, WebhookTriggerConfig } from '../../../../platform/registry/types'

/**
 * Instantly webhook payload structure
 *
 * Uses snake_case matching Instantly's API. Workflows receive this directly.
 */
export interface InstantlyReplyWebhookPayload {
  timestamp: string
  event_type: 'reply_received'
  workspace: string
  campaign_id: string
  campaign_name?: string
  lead_email: string
  email_account: string
  unibox_url: string
  reply_to_uuid: string
  reply_subject: string
  reply_text: string
  reply_text_snippet: string
  reply_html: string
  step: number
  variant: number
  is_first: boolean
}

/**
 * Instantly Reply Received Trigger Definition
 *
 * Trigger type: webhook
 * Provider: instantly
 * Event: reply_received
 */
export const instantlyReplyReceivedTrigger: TriggerDefinition = {
  resourceId: 'trigger-instantly-reply-received',
  type: 'trigger',
  triggerType: 'webhook',
  name: 'Instantly Reply Received',
  description: 'Webhook fired when a lead replies to an Instantly email campaign',
  version: '1.0.0',
  status: 'dev',
  webhookPath: '/webhooks/instantly/reply-received',
  config: {
    provider: 'instantly',
    event: 'reply_received'
  } as WebhookTriggerConfig
}
