package channel // ChannelTwilioSMS represents a Twilio SMS channel configuration. // Reference: Twilio SMS API — https://www.twilio.com/docs/sms // + Chatwoot app/models/channel/twilio_sms.rb (partial — Chatwoot uses Twilio for SMS + WhatsApp) // // GoChat addition — full Twilio SMS integration. // The Twilio SMS channel connects Twilio phone numbers to gochat conversations. // // Key Twilio API concepts: // - Account SID: Twilio account identifier // - Auth Token: Twilio authentication token (used for API + webhook verification) // - Phone Number: the Twilio phone number sending/receiving SMS // - Messaging Service SID: optional, for grouped phone numbers // - Webhook: Twilio sends inbound messages to a configured URL // // Design notes: // - Uses GORM soft-delete pattern consistent with other channel models // - JSON field tags follow snake_case convention per P2D §7 // - Twilio supports both SMS and WhatsApp via the same API — this model // handles SMS only; WhatsApp has its own ChannelWhatsApp model // - Sensitive fields (auth_token) are stored in Inbox.ChannelConfig import "gorm.io/gorm" // ChannelTwilioSMS is the GORM model for Twilio SMS channels. // Reference: Chatwoot app/models/channel/twilio_sms.rb // Design: Follows the same pattern as ChannelTelegram — minimal GORM model with // config stored in Inbox.ChannelConfig (JSONB). type ChannelTwilioSMS struct { gorm.Model // Twilio Account SID // Unique identifier for the Twilio subaccount AccountSID string `json:"account_sid" gorm:"type:varchar(255);not null"` // Phone number assigned to this channel (Twilio purchased number) PhoneNumber string `json:"phone_number" gorm:"type:varchar(50);uniqueIndex;not null"` // Messaging Service SID (optional) // Used when multiple phone numbers are grouped under a messaging service MessagingServiceSID string `json:"messaging_service_sid" gorm:"type:varchar(255)"` // AccountID references the owning gochat account (multi-tenant) AccountID uint `json:"account_id" gorm:"index;not null"` // InboxID references the associated inbox (1:1 with channel) InboxID uint `json:"inbox_id" gorm:"uniqueIndex;not null"` } // TableName overrides GORM table name convention. func (ChannelTwilioSMS) TableName() string { return "channel_twilio_sms" } // Channelable interface implementation for ChannelTwilioSMS. func (c *ChannelTwilioSMS) GetChannelType() string { return "twilio_sms" } func (c *ChannelTwilioSMS) GetChannelID() string { return c.AccountSID } func (c *ChannelTwilioSMS) GetName() string { return c.PhoneNumber } func (c *ChannelTwilioSMS) GetAccountID() uint { return c.AccountID } func (c *ChannelTwilioSMS) GetInboxID() uint { return c.InboxID } func (c *ChannelTwilioSMS) SetInboxID(id uint) { c.InboxID = id }