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

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

/**
 * Instantly auto reply received webhook payload structure
 *
 * Uses snake_case matching Instantly's API. Workflows receive this directly.
 */
export interface InstantlyAutoReplyReceivedPayload {
  timestamp: string
  event_type: 'auto_reply_received'
  workspace: string
  campaign_id: string
  campaign_name?: string
  lead_email: string
  email_account: string
  reply_subject?: string
  reply_text?: string
  reply_text_snippet?: string
  step?: number
  variant?: number
}

/**
 * Instantly Auto Reply Received Trigger Definition
 *
 * Trigger type: webhook
 * Provider: instantly
 * Event: auto_reply_received
 */
export const instantlyAutoReplyReceivedTrigger: TriggerDefinition = {
  resourceId: 'trigger-instantly-auto-reply-received',
  type: 'trigger',
  triggerType: 'webhook',
  name: 'Instantly Auto Reply Received',
  description:
    'Webhook fired when an automated reply (out-of-office, auto-responder) is received for an Instantly campaign email',
  version: '1.0.0',
  status: 'dev',
  webhookPath: '/webhooks/instantly/auto-reply-received',
  config: {
    provider: 'instantly',
    event: 'auto_reply_received'
  } as WebhookTriggerConfig
}
