Documentation
¶
Overview ¶
Package texting is ReputeCast's SMS channel (design expansion phase 8, M31): SMS providers and their senders with the carriers' registrations, routing by country, the SMS rules (keywords and replies, quiet hours, the brand prefix and opt-out text, the budget and auto-pause thresholds, the short-link domain), phone numbers and SMS consent per list, the SMS suppression list, SMS campaigns from the composer to the report, the Send SMS automation step, provider webhooks and the text message terms page.
Providers are reached through internal/sms only; the channel model it shares with push and WhatsApp is internal/channels. Texts, receipts, replies and clicks stay in the message log for 90 days, never in the audit log; everything a person or key changes is audited.
Index ¶
- Constants
- Variables
- func Erasure() erasure.Source
- func LinkCode(seed uuid.UUID, contact uuid.UUID, i int) string
- func Register(h huma.API, s *Service)
- func RegisterJobs(reg *jobs.Registry, s *Service)
- type Approvals
- type Audience
- type CountryLine
- type Decision
- type DispatchArgs
- type DispatchWorker
- type Evidence
- type Funnel
- type HealthArgs
- type HealthWorker
- type ImportTexts
- type Link
- type Measured
- type NormalizeArgs
- type NormalizeWorker
- type PrefEvidence
- type PrefTexts
- type PublicTermsLink
- type PublicTermsPage
- type PublicTermsSection
- type Recipient
- type Reg
- type Rules
- type SegmentResolver
- type Service
- func (s *Service) AccountNumbers(ctx context.Context, ws *store.Workspace, providerID uuid.UUID) (SmsFoundSenderList, error)
- func (s *Service) Act(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) error
- func (s *Service) AddSenderID(ctx context.Context, ws *store.Workspace, p *authz.Principal, ...) ([]SmsSenderRow, error)
- func (s *Service) AddSuppressions(ctx context.Context, ws *store.Workspace, p *authz.Principal, ...) (int, error)
- func (s *Service) AddTestNumber(ctx context.Context, ws *store.Workspace, p *authz.Principal, ...) (SmsRules, error)
- func (s *Service) AgentDraft(ctx context.Context, ws *store.Workspace, p *authz.Principal, ...) (map[string]any, error)
- func (s *Service) AgentOverview(ctx context.Context, ws *store.Workspace, p *authz.Principal) (map[string]any, error)
- func (s *Service) AgentReport(ctx context.Context, ws *store.Workspace, p *authz.Principal, ref string) (map[string]any, string, string, error)
- func (s *Service) Catalog(ctx context.Context, ws *store.Workspace) ([]SmsCatalogItem, error)
- func (s *Service) CheckNow(ctx context.Context, ws *store.Workspace, id uuid.UUID) (SmsOverview, error)
- func (s *Service) CheckPages(ctx context.Context, ws *store.Workspace, p *authz.Principal, ...) (SmsRegistrationPanel, error)
- func (s *Service) CheckProvider(ctx context.Context, p store.SmsProvider) error
- func (s *Service) CheckShortDomain(ctx context.Context, ws *store.Workspace, p *authz.Principal) (SmsRules, error)
- func (s *Service) Connect(ctx context.Context, ws *store.Workspace, p *authz.Principal, ...) (SmsConnectResult, error)
- func (s *Service) ContactActivity(ctx context.Context, ws *store.Workspace, contactID uuid.UUID, ...) ([]audience.ContactActivityItem, int64, error)
- func (s *Service) ContactChannels(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (SmsContactChannels, error)
- func (s *Service) Create(ctx context.Context, ws *store.Workspace, p *authz.Principal, ...) (SmsCampaign, error)
- func (s *Service) DescribeForApproval(ctx context.Context, ws *store.Workspace, campaignID uuid.UUID) (approvals.ChannelCampaign, error)
- func (s *Service) Dispatch(ctx context.Context, budget time.Duration) (again time.Duration, done bool, err error)
- func (s *Service) Duplicate(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (SmsCampaign, error)
- func (s *Service) Events(ctx context.Context, ws *store.Workspace, f SmsEventFilter) (SmsEventList, error)
- func (s *Service) FillChannelRows(ctx context.Context, ws *store.Workspace, items []campaigns.CampaignListItem)
- func (s *Service) FinishSetup(ctx context.Context, ws *store.Workspace, p *authz.Principal, ...) error
- func (s *Service) Get(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (SmsCampaign, error)
- func (s *Service) HookRoutes(r chi.Router)
- func (s *Service) ImportSenders(ctx context.Context, ws *store.Workspace, p *authz.Principal, ...) ([]SmsSenderRow, error)
- func (s *Service) Ingest(ctx context.Context, adapter, token string, r *http.Request, body []byte) int
- func (s *Service) LinkRoutes(r chi.Router, spa http.Handler)
- func (s *Service) Message(ctx context.Context, ws *store.Workspace, id uuid.UUID) (SmsMessageView, error)
- func (s *Service) MessageOptions(ctx context.Context, ws *store.Workspace) ([]SmsMessageOption, error)
- func (s *Service) MoveScheduled(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) error
- func (s *Service) Normalize(ctx context.Context, rawID uuid.UUID) error
- func (s *Service) Overview(ctx context.Context, ws *store.Workspace, p *authz.Principal) (SmsOverview, error)
- func (s *Service) PinSetting(ctx context.Context, p store.SmsProvider, key, value string) (string, error)
- func (s *Service) Prefs(ctx context.Context, ws *store.Workspace, contactID uuid.UUID, code string) (PrefTexts, bool)
- func (s *Service) Preview(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) (SmsPreview, error)
- func (s *Service) PreviewContacts(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) ([]SmsPreviewContact, error)
- func (s *Service) ProviderTest(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) (SmsMessageView, error)
- func (s *Service) PublicTerms(ctx context.Context, ws *store.Workspace) (TermsPage, bool)
- func (s *Service) PublicTermsPage(ctx context.Context, ws *store.Workspace, lang i18n.Lang, code string) (PublicTermsPage, bool)
- func (s *Service) PublishTerms(ctx context.Context, ws *store.Workspace, p *authz.Principal, ...) (SmsTerms, error)
- func (s *Service) ReadPrices(ctx context.Context, p store.SmsProvider) error
- func (s *Service) ReadRegistrations(ctx context.Context, p store.SmsProvider) error
- func (s *Service) RegisterWebhooks(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (SmsWebhookSetup, error)
- func (s *Service) Registration(ctx context.Context, ws *store.Workspace, p *authz.Principal, ...) (SmsRegistrationPanel, error)
- func (s *Service) RemoveProvider(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) error
- func (s *Service) RemoveSender(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) error
- func (s *Service) RemoveSuppression(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) error
- func (s *Service) RemoveTestNumber(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (SmsRules, error)
- func (s *Service) ReplaceCredentials(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) error
- func (s *Service) Replies(ctx context.Context, ws *store.Workspace, id uuid.UUID, kind string, ...) (SmsReplyList, error)
- func (s *Service) Report(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (SmsReport, error)
- func (s *Service) ReportCSV(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (*SmsCSV, error)
- func (s *Service) Review(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (SmsReview, error)
- func (s *Service) RouteTest(ctx context.Context, ws *store.Workspace, in SmsRouteTestInput) (SmsRouteTest, error)
- func (s *Service) Rules(ctx context.Context, ws *store.Workspace, p *authz.Principal) (SmsRules, error)
- func (s *Service) SavePrefs(ctx context.Context, tx pgx.Tx, ws *store.Workspace, contactID uuid.UUID, ...) ([]uuid.UUID, error)
- func (s *Service) SaveRoutes(ctx context.Context, ws *store.Workspace, p *authz.Principal, ...) (SmsRules, error)
- func (s *Service) SaveRules(ctx context.Context, ws *store.Workspace, p *authz.Principal, in SmsRulesInput) (SmsRules, error)
- func (s *Service) SaveSendSettings(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) (SmsReview, error)
- func (s *Service) Send(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) (SmsSendResult, error)
- func (s *Service) SendConfirmation(ctx context.Context, ws *store.Workspace, contactID, listID uuid.UUID)
- func (s *Service) SendTest(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) ([]SmsTestNumber, error)
- func (s *Service) SetConsent(ctx context.Context, q *store.Queries, ws *store.Workspace, ...) (bool, error)
- func (s *Service) SetConsentByTeam(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) (SmsContactChannels, error)
- func (s *Service) SetPhone(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) (SmsContactChannels, error)
- func (s *Service) SetRegistration(ctx context.Context, ws *store.Workspace, p *authz.Principal, ...) (SmsRegistrationPanel, error)
- func (s *Service) SetShortDomain(ctx context.Context, ws *store.Workspace, p *authz.Principal, ...) (SmsRules, error)
- func (s *Service) StepEstimate(ctx context.Context, ws *store.Workspace, in SmsStepEstimateInput) (SmsStepEstimate, error)
- func (s *Service) StepStats(ctx context.Context, ws *store.Workspace, automationID uuid.UUID) (SmsStepStatsList, error)
- func (s *Service) Suppressions(ctx context.Context, ws *store.Workspace, p *authz.Principal, ...) (SmsSuppressionList, error)
- func (s *Service) Sweep(ctx context.Context) error
- func (s *Service) SyncOptOuts(ctx context.Context, p store.SmsProvider) error
- func (s *Service) Terms(ctx context.Context, ws *store.Workspace, p *authz.Principal) (SmsTerms, error)
- func (s *Service) TermsURL(ctx context.Context, ws *store.Workspace) string
- func (s *Service) Unschedule(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) error
- func (s *Service) Update(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) (SmsCampaign, error)
- func (s *Service) UpdateSender(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) ([]SmsSenderRow, error)
- func (s *Service) Versions(ctx context.Context, ws *store.Workspace, id uuid.UUID) ([]SmsCampaignVersion, error)
- type ShortDomainsArgs
- type ShortDomainsWorker
- type SignupTexts
- func (t SignupTexts) Confirm(ctx context.Context, ws *store.Workspace, contactID uuid.UUID, ...)
- func (t SignupTexts) Offer(ctx context.Context, ws *store.Workspace, code string) (forms.TextOffer, bool)
- func (t SignupTexts) Save(ctx context.Context, tx pgx.Tx, ws *store.Workspace, contactID uuid.UUID, ...) (bool, error)
- func (SignupTexts) Texted(code, e164 string) string
- func (t SignupTexts) TextedContact(ctx context.Context, ws *store.Workspace, contactID uuid.UUID, code string) string
- type SmsAudienceRef
- type SmsBudgetView
- type SmsCSV
- type SmsCampaign
- type SmsCampaignAccess
- type SmsCampaignCreate
- type SmsCampaignPath
- type SmsCampaignUpdate
- type SmsCampaignVersion
- type SmsCampaignVersionList
- type SmsCatalogItem
- type SmsCatalogList
- type SmsChannels
- type SmsCheck
- type SmsCheckSender
- type SmsClickLink
- type SmsConnectInput
- type SmsConnectResult
- type SmsConsentEvent
- type SmsConsentEvidence
- type SmsConsentInput
- type SmsContactChannels
- type SmsContactList
- type SmsContactPath
- type SmsCounter
- type SmsCountryReport
- type SmsCredentialsInput
- type SmsEvent
- type SmsEventFilter
- type SmsEventList
- type SmsFailureCode
- type SmsFailureReason
- type SmsField
- type SmsFoundSender
- type SmsFoundSenderList
- type SmsFunnel
- type SmsHeld
- type SmsIDPath
- type SmsImportInput
- type SmsImportSender
- type SmsLarge
- type SmsLinkView
- type SmsLongest
- type SmsMemberOption
- type SmsMessageEvent
- type SmsMessageOption
- type SmsMessageOptionList
- type SmsMessageView
- type SmsOptOutSyncRow
- type SmsOutageView
- type SmsOverview
- type SmsOverviewTiles
- type SmsPageCheck
- type SmsPauseView
- type SmsPhoneInput
- type SmsPreview
- type SmsPreviewBubble
- type SmsPreviewContact
- type SmsPreviewContactList
- type SmsPreviewInput
- type SmsPreviewPart
- type SmsProviderCard
- type SmsProviderCount
- type SmsProviderPath
- type SmsProviderSpend
- type SmsProviderTestInput
- type SmsRegistrationHelper
- type SmsRegistrationInput
- type SmsRegistrationPanel
- type SmsRegistrationView
- type SmsReply
- type SmsReplyList
- type SmsReplyView
- type SmsReport
- type SmsReportTiles
- type SmsReview
- type SmsReviewCampaign
- type SmsReviewPolicy
- type SmsReviewRoute
- type SmsRouteGap
- type SmsRouteInput
- type SmsRouteLine
- type SmsRouteSummary
- type SmsRouteTest
- type SmsRouteTestInput
- type SmsRouteView
- type SmsRoutesInput
- type SmsRules
- type SmsRulesInput
- type SmsSchedule
- type SmsSendAction
- type SmsSendInput
- type SmsSendResult
- type SmsSendSettings
- type SmsSendView
- type SmsSenderIDInput
- type SmsSenderOption
- type SmsSenderPath
- type SmsSenderReport
- type SmsSenderRow
- type SmsSenderRows
- type SmsSenderUpdate
- type SmsShortDomain
- type SmsShortDomainInput
- type SmsSpread
- type SmsStep
- func (st SmsStep) Condition(ctx context.Context, tx pgx.Tx, in automations.ChannelCheck) (bool, time.Time, error)
- func (st SmsStep) CostSince(ctx context.Context, workspaceID uuid.UUID, automationIDs []uuid.UUID, ...) (map[uuid.UUID]float64, error)
- func (SmsStep) Permission() authz.Permission
- func (st SmsStep) PublishChecks(ctx context.Context, workspaceID uuid.UUID, nodes []automations.AutomationNode) ([]automations.AutomationPublishCheck, error)
- func (st SmsStep) Send(ctx context.Context, tx pgx.Tx, in automations.ChannelSend) (automations.ChannelSent, error)
- func (SmsStep) Validate(n automations.AutomationNode) []automations.ChannelIssue
- type SmsStepEstimate
- type SmsStepEstimateInput
- type SmsStepStats
- type SmsStepStatsList
- type SmsSuppression
- type SmsSuppressionAdd
- type SmsSuppressionFilter
- type SmsSuppressionList
- type SmsSuppressionProvider
- type SmsSuppressionRemove
- type SmsSuppressionsAdded
- type SmsTerms
- type SmsTermsContent
- type SmsTestInput
- type SmsTestNumber
- type SmsTestNumberInput
- type SmsTestNumberList
- type SmsTestResult
- type SmsThresholds
- type SmsTimePoint
- type SmsTimelineSample
- type SmsTimelineSampleEv
- type SmsWebhookSetup
- type SmsZoneGroup
- type SmsZoneNow
- type SmsZoneStep
- type Spread
- type SweepArgs
- type SweepWorker
- type TermsPage
- type Text
Constants ¶
const ( MetricFailed = "failed" MetricFiltered = "filtered" MetricOptOuts = "opt_outs" )
Auto-pause metrics.
const ( FilteredLimit = 3 FilteredWindow = 30 * 24 * time.Hour )
FilteredLimit: a number filtered by carriers this many times in FilteredWindow goes on the suppression list.
const ( LargeRecipients = 1000 LargeCost = 100.0 )
LargeRecipients and LargeCost: sends above these ask for the recipient count to be typed.
const ( VerdictReady = "ready" VerdictWarnings = "warnings" VerdictBlocked = "blocked" Pass = "pass" Warn = "warn" Block = "block" )
Check verdicts and statuses.
const CodeLength = 6
CodeLength is a short link's code: go.acme.io/k3P9xq.
const EventRetention = 90 * 24 * time.Hour
EventRetention is how long delivery events and raw webhooks are kept.
const MaxHookBody = 1 << 20
MaxHookBody is the largest SMS webhook accepted.
const MinSentForPause = 50
MinSentForPause: a rate counts once this many texts went out.
const ( // ReceiptsSilentAfter: texts sent and no receipt for this long. ReceiptsSilentAfter = 2 * time.Hour )
Health thresholds.
Variables ¶
var ErrNotFound = errors.New("texting: not found")
ErrNotFound reports a missing row.
Functions ¶
func Erasure ¶
Erasure is what SMS, WhatsApp and push keep about a contact in the shared channel tables: consents with their proof, messages and their events, replies and link clicks. Messages stay, without the number or text, so costs and campaign counts still add up (review 2026-11 DP-1).
func LinkCode ¶
LinkCode is the code of a recipient's i-th link in a message: derived from the message, so a preview shows the code the person gets.
func RegisterJobs ¶
RegisterJobs adds the SMS workers and their schedules.
Types ¶
type Approvals ¶
type Approvals interface {
ChannelGate(ctx context.Context, ws *store.Workspace, p *authz.Principal, campaignID uuid.UUID) (*store.ApprovalRequest, error)
ChannelReview(ctx context.Context, ws *store.Workspace, p *authz.Principal, campaignID uuid.UUID) (approvals.ReviewApproval, error)
}
Approvals is the approval flow (internal/approvals): the workspace's rules and requests apply to SMS campaigns as to email ones.
type Audience ¶
type Audience struct {
Lists []string `json:"lists,omitempty"`
Segments []string `json:"segments,omitempty"`
}
Audience is an SMS campaign's audience: lists and segments, stored like an email campaign's.
type CountryLine ¶
type CountryLine struct {
Country string `json:"country"`
Recipients int64 `json:"recipients"`
Skipped int64 `json:"skipped"`
SkipReason string `json:"skipReason,omitempty"`
Sender string `json:"sender"`
SenderKind string `json:"senderKind"`
Provider string `json:"provider"`
Adapter string `json:"adapter"`
Segments int `json:"segments"`
Price float64 `json:"price"`
// PendingPrice is the price once a pending sender is approved.
PendingPrice float64 `json:"pendingPrice"`
Cost float64 `json:"cost"`
}
CountryLine is one country of a campaign's cost table.
type Decision ¶
type Decision struct {
Country string
// Route is the route that covers the country; nil for "every other
// country".
Route *store.SmsRoute
// Sender is who sends, nil when nobody can: Hold says why.
Sender *store.SmsSendersRow
// Fallback takes over when the sender's provider is down; nil is
// "None: hold and notify".
Fallback *store.SmsSendersRow
Reg Reg
// Price is the price of one segment; 0 when unknown.
Price float64
PriceOn *time.Time
// Hold is why nothing can send: no_route (every other country: don't
// send), or the sender's registration (pending, rejected,
// not_registered, not_supported).
Hold string
}
Decision is where a text to a country goes.
type DispatchArgs ¶
type DispatchArgs struct{}
DispatchArgs sends the texts that are due.
func (DispatchArgs) InsertOpts ¶
func (DispatchArgs) InsertOpts() river.InsertOpts
InsertOpts implements river.JobArgsWithInsertOpts.
type DispatchWorker ¶
type DispatchWorker struct {
river.WorkerDefaults[DispatchArgs]
S *Service
}
DispatchWorker runs DispatchArgs.
func (*DispatchWorker) NextRetry ¶
func (w *DispatchWorker) NextRetry(job *river.Job[DispatchArgs]) time.Time
NextRetry implements river.Worker: a failed run goes again within seconds.
func (*DispatchWorker) Timeout ¶
func (w *DispatchWorker) Timeout(*river.Job[DispatchArgs]) time.Duration
Timeout bounds one run.
func (*DispatchWorker) Work ¶
func (w *DispatchWorker) Work(ctx context.Context, _ *river.Job[DispatchArgs]) error
Work implements river.Worker.
type Evidence ¶
type Evidence struct {
// Source is how it happened: form:<slug>, preference_center,
// account_page, import:<file>, api, team.
Source string
Page string
ConsentText string
ConsentVersion string
IP string
UserAgent string
ActorID *uuid.UUID
ImportID *uuid.UUID
Note string
At time.Time
}
Evidence is what a consent change is recorded with.
type Funnel ¶
type Funnel struct {
// Base is everyone on the audience's lists and segments.
Base int64
// NoConsent have no number, or no SMS consent on a list of the
// audience (any list for a segment): email sign-ups never count.
NoConsent int64
// Suppressed have consent but their number is on the SMS suppression
// list, by reason.
Suppressed int64
SuppressedByReason map[string]int64
// a phone gets one text.
Shared int64
// CanReceive are the recipients.
CanReceive int64
Recipients []Recipient
// Assumed is how many recipients' time zone comes from their number.
Assumed int64
AssumedByArea int64
}
Funnel is how an audience narrows to the people who can receive texts.
type HealthArgs ¶
type HealthArgs struct{}
HealthArgs is the provider health job's SMS pass: credentials, receipts, registration statuses, prices and opt-out lists.
func (HealthArgs) InsertOpts ¶
func (HealthArgs) InsertOpts() river.InsertOpts
InsertOpts implements river.JobArgsWithInsertOpts.
type HealthWorker ¶
type HealthWorker struct {
river.WorkerDefaults[HealthArgs]
S *Service
}
HealthWorker runs HealthArgs.
func (*HealthWorker) Timeout ¶
func (w *HealthWorker) Timeout(*river.Job[HealthArgs]) time.Duration
Timeout bounds one pass.
func (*HealthWorker) Work ¶
func (w *HealthWorker) Work(ctx context.Context, _ *river.Job[HealthArgs]) error
Work implements river.Worker.
type ImportTexts ¶
type ImportTexts struct{ S *Service }
ImportTexts is texting's side of imports (imports.Texts).
func (ImportTexts) DefaultCountry ¶
DefaultCountry implements imports.Texts: the first country the workspace routes texts to.
func (ImportTexts) Import ¶
func (t ImportTexts) Import(ctx context.Context, tx pgx.Tx, ws *store.Workspace, contactID, listID uuid.UUID, row imports.TextRow) (imports.TextOutcome, error)
Import implements imports.Texts. A contact's number is kept unless the conflict rule overwrites it; SMS consent goes with the contact's number only.
type Link ¶
type Link struct {
// URL as written ("acme.io/summit/agenda").
URL string
// Host is its host, lower case.
Host string
// Shortener is set when the host is a public shortener (blocked).
Shortener bool
// Start and End are byte offsets in the body.
Start, End int
}
Link is a link in a text.
type Measured ¶
type Measured struct {
// Count is the text with every token at its fallback and links at a
// short link's length.
Count sms.Count
// Base is the length without the personalized parts.
Base int
// Fields are the fields that change the length.
Fields []liquid.Use
Links []Link
}
Measured is how a text counts for the composer.
type NormalizeArgs ¶
NormalizeArgs normalizes one stored SMS webhook.
func (NormalizeArgs) InsertOpts ¶
func (NormalizeArgs) InsertOpts() river.InsertOpts
InsertOpts implements river.JobArgsWithInsertOpts.
type NormalizeWorker ¶
type NormalizeWorker struct {
river.WorkerDefaults[NormalizeArgs]
S *Service
}
NormalizeWorker runs NormalizeArgs.
func (*NormalizeWorker) NextRetry ¶
func (w *NormalizeWorker) NextRetry(job *river.Job[NormalizeArgs]) time.Time
NextRetry implements river.Worker.
func (*NormalizeWorker) Work ¶
func (w *NormalizeWorker) Work(ctx context.Context, job *river.Job[NormalizeArgs]) error
Work implements river.Worker.
type PrefEvidence ¶
PrefEvidence is the request a switch was changed in, and where: preference_center (default) or account_page.
type PrefTexts ¶
type PrefTexts struct {
// Phone is the number, masked: +1 312 ••• 0123.
Phone string
Label string
Note string
// Save is the account page's button.
Save string
// On is SMS consent per list (subscribed or waiting for YES).
On map[uuid.UUID]bool
// Locked is true when the number replied STOP: the switches are off
// and stay off here.
Locked bool
}
PrefTexts is the preference center's texts for a contact, in a language.
type PublicTermsLink ¶
PublicTermsLink is words to link and where.
type PublicTermsPage ¶
type PublicTermsPage struct {
Lang, Title, Version, Intro string
Sections []PublicTermsSection
ClosingHeading, ClosingText string
}
PublicTermsPage is the public page with every word written: the terms' own text, and the page's headings in lang (English until translated).
type PublicTermsSection ¶
type PublicTermsSection struct {
Heading, Text string
Links []PublicTermsLink
}
PublicTermsSection is a heading and its text; Links are words in the text that link somewhere (a number, an address, the privacy policy).
type Recipient ¶
type Recipient struct {
ContactID uuid.UUID
ListID uuid.UUID
Phone string
Country string
FirstName string
LastName string
Email string
Attributes map[string]any
Zone string
ZoneSource phone.ZoneSource
}
Recipient is one person a text can go to.
type Reg ¶
type Reg struct {
Status string
// Kind is what the status comes from: toll_free, brand, campaign,
// sender_id, or "" when nothing was recorded.
Kind string
Name string
Reason string
Since *time.Time
Source string
// Brand and Campaign are a 10DLC number's two registrations.
Brand, Campaign *store.SmsRegistrationsRow
}
Reg is a sender's effective registration in one country.
type Rules ¶
type Rules struct {
BrandPrefix string
OptOutText string
OptOutInSteps bool
ConfirmationOn bool
Confirmation string
RequireYes bool
Window channels.Window
PushWindow bool
WhatsAppWindow bool
Keywords sms.Keywords
HelpReply string
OptOutReply string
OptInReply string
KeywordsBy string
Budget float64
BudgetAlertPct int
BudgetSetBy *uuid.UUID
BudgetSetAt *time.Time
PauseFailed float64
PauseFiltered float64
PauseOptOut float64
OtherCountries string
OtherRouteID *uuid.UUID
RetentionDays int
ShortDomain string
ShortStatus string
ShortTarget string
ShortCheckedAt *time.Time
ShortVerifiedAt *time.Time
ShortDetail string
UpdatedBy *uuid.UUID
UpdatedAt time.Time
}
Rules are the workspace's SMS rules, as code reads them.
type SegmentResolver ¶
type SegmentResolver interface {
ContactIDs(ctx context.Context, workspaceID, segmentID uuid.UUID) ([]uuid.UUID, error)
}
SegmentResolver lists a segment's contacts.
type Service ¶
type Service struct {
Pool *pgxpool.Pool
Q *store.Queries
Audit *audit.Logger
Box *secrets.Box
Log *slog.Logger
URLs publicurl.Builder
// Hosts says whose host a request came to: /t/s/ answers on a host a
// workspace holds for that workspace's codes only (nil: on a
// short-link domain only, as its root does).
Hosts *customhost.Hosts
// Jobs enqueues River jobs (read at call time: the client is built after
// the services).
Jobs func() *jobs.Client
Now func() time.Time
// HTTP is the SSRF-guarded client providers are called through.
HTTP *http.Client
// DNS checks the short-link domain's CNAME.
DNS dnscheck.Resolver
// Demo answers a demo provider's calls in process: its client and base
// URL. The demo's sample providers never reach the real provider.
Demo func(adapter string) (*http.Client, string)
// Segments resolves a segment's contacts for an audience.
Segments SegmentResolver
// Approvals evaluates the workspace's approval rules for SMS campaigns
// and holds their requests (internal/approvals, through the app).
Approvals Approvals
// PageBase is the workspace's own site address (https://news.acme.io)
// when it has a verified custom domain, for the terms page's address.
PageBase func(ctx context.Context, ws *store.Workspace) string
// Emit sends outgoing webhook events (internal/webhooks).
Emit func(ctx context.Context, q store.DBTX, ws *store.Workspace, event string, data any) error
// Changed re-checks a campaign's open approval after an edit.
Changed func(ctx context.Context, ws *store.Workspace, campaignID uuid.UUID)
// DemoReceipt builds the delivery receipt a demo provider's fake would
// send for a text, signed as the provider signs it; the demo plays it
// back through the webhook path a few seconds after the send. False
// when the adapter has no fake.
DemoReceipt func(adapter string, cfg sms.Config, hookURL, providerMessageID, to, from string, at time.Time) (*http.Request, []byte, bool)
}
Service is the SMS domain.
func (*Service) AccountNumbers ¶
func (s *Service) AccountNumbers(ctx context.Context, ws *store.Workspace, providerID uuid.UUID) (SmsFoundSenderList, error)
AccountNumbers lists the numbers in a provider's account with their registration, marking the ones already imported (Import from providers).
func (*Service) Act ¶
func (s *Service) Act(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in SmsSendAction) error
Act pauses, resumes or cancels a send. Pausing needs campaigns:pause; resuming needs campaigns:send and sms:send; cancelling either.
func (*Service) AddSenderID ¶
func (s *Service) AddSenderID(ctx context.Context, ws *store.Workspace, p *authz.Principal, in SmsSenderIDInput) ([]SmsSenderRow, error)
AddSenderID adds a sender ID with its countries; each country starts as allowed or not registered, and its status is set here by hand when the provider doesn't report it. Audited.
func (*Service) AddSuppressions ¶
func (s *Service) AddSuppressions(ctx context.Context, ws *store.Workspace, p *authz.Principal, in SmsSuppressionAdd) (int, error)
AddSuppressions puts numbers on the list (reason Manual).
func (*Service) AddTestNumber ¶
func (s *Service) AddTestNumber(ctx context.Context, ws *store.Workspace, p *authz.Principal, in SmsTestNumberInput) (SmsRules, error)
AddTestNumber adds a test number. Audited.
func (*Service) AgentDraft ¶
func (s *Service) AgentDraft(ctx context.Context, ws *store.Workspace, p *authz.Principal, name, body string, lists []string) (map[string]any, error)
AgentDraft drafts a text campaign for an agent: a name, the text between the rules' brand prefix and opt-out text, and lists by name or id.
func (*Service) AgentOverview ¶
func (s *Service) AgentOverview(ctx context.Context, ws *store.Workspace, p *authz.Principal) (map[string]any, error)
AgentOverview is the SMS providers page for an agent: providers, senders and their registrations, routes by country, the month's spend against the budget. No phone numbers of contacts.
func (*Service) AgentReport ¶
func (s *Service) AgentReport(ctx context.Context, ws *store.Workspace, p *authz.Principal, ref string) (map[string]any, string, string, error)
AgentReport is a text campaign's report for an agent: totals, countries, failures with the providers' codes, links and replies by kind. Counts only: no numbers or reply texts.
func (*Service) CheckNow ¶
func (s *Service) CheckNow(ctx context.Context, ws *store.Workspace, id uuid.UUID) (SmsOverview, error)
CheckNow probes a provider at once ("Retry now" during an outage).
func (*Service) CheckPages ¶
func (s *Service) CheckPages(ctx context.Context, ws *store.Workspace, p *authz.Principal, senderID uuid.UUID) (SmsRegistrationPanel, error)
CheckPages asks the pages carriers check (the terms page and the sign-up page) and records how they answered.
func (*Service) CheckProvider ¶
CheckProvider probes a provider now (its credentials and account).
func (*Service) CheckShortDomain ¶
func (s *Service) CheckShortDomain(ctx context.Context, ws *store.Workspace, p *authz.Principal) (SmsRules, error)
CheckShortDomain checks the short-link domain's CNAME now.
func (*Service) Connect ¶
func (s *Service) Connect(ctx context.Context, ws *store.Workspace, p *authz.Principal, in SmsConnectInput) (SmsConnectResult, error)
Connect checks the credentials, registers the webhooks where the API allows it, and lists the senders in the account. The credentials are sealed and never returned. Audited.
func (*Service) ContactActivity ¶
func (s *Service) ContactActivity(ctx context.Context, ws *store.Workspace, contactID uuid.UUID, before *time.Time, beforeID string, limit int) ([]audience.ContactActivityItem, int64, error)
ContactActivity puts a contact's texts on their timeline (implements audience.ActivitySource): each text with its status, clicks on its links and replies, and every change of SMS consent with its evidence.
func (*Service) ContactChannels ¶
func (s *Service) ContactChannels(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (SmsContactChannels, error)
ContactChannels is the contact profile's "Consent per list" card.
func (*Service) Create ¶
func (s *Service) Create(ctx context.Context, ws *store.Workspace, p *authz.Principal, in SmsCampaignCreate) (SmsCampaign, error)
Create makes an SMS campaign (Regular only), audited like any campaign.
func (*Service) DescribeForApproval ¶
func (s *Service) DescribeForApproval(ctx context.Context, ws *store.Workspace, campaignID uuid.UUID) (approvals.ChannelCampaign, error)
DescribeForApproval implements approvals.ChannelCampaigns.
func (*Service) Dispatch ¶
func (s *Service) Dispatch(ctx context.Context, budget time.Duration) (again time.Duration, done bool, err error)
Dispatch sends due texts for up to budget. again is when to look next; done is true when nothing is queued at all.
func (*Service) Duplicate ¶
func (s *Service) Duplicate(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (SmsCampaign, error)
Duplicate copies an SMS campaign's text and audience into a new draft ("Copy of …", in the language of whoever duplicates it, as email and WhatsApp campaigns are named), whatever its status, audited like any new campaign.
func (*Service) Events ¶
func (s *Service) Events(ctx context.Context, ws *store.Workspace, f SmsEventFilter) (SmsEventList, error)
Events lists raw provider events beside their normalized ones.
func (*Service) FillChannelRows ¶
func (s *Service) FillChannelRows(ctx context.Context, ws *store.Workspace, items []campaigns.CampaignListItem)
FillChannelRows fills in the campaigns list's SMS rows (implements campaigns.ChannelRows): the providers and how many texts each takes ("Twilio 659 · Vonage 195"), the results once texts went out (delivered, clicks, opt-outs, cost), and the review's verdict before the send.
func (*Service) FinishSetup ¶
func (s *Service) FinishSetup(ctx context.Context, ws *store.Workspace, p *authz.Principal, setupID uuid.UUID) error
FinishSetup closes the wizard. Audited.
func (*Service) Get ¶
func (s *Service) Get(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (SmsCampaign, error)
Get returns the composer's view of an SMS campaign.
func (*Service) HookRoutes ¶
HookRoutes mounts the SMS webhook endpoint: receipts and inbound texts from every SMS provider, one address per connected provider.
func (*Service) ImportSenders ¶
func (s *Service) ImportSenders(ctx context.Context, ws *store.Workspace, p *authz.Principal, providerID uuid.UUID, in SmsImportInput) ([]SmsSenderRow, error)
ImportSenders adds numbers from the provider's account and reads their registrations. Audited.
func (*Service) Ingest ¶
func (s *Service) Ingest(ctx context.Context, adapter, token string, r *http.Request, body []byte) int
Ingest verifies one webhook, stores it raw and queues its normalization, answering the status code for the provider: 200 at once, 401 when the signature fails (the payload is kept, cut short, for diagnosis), 404 for an unknown address, 429 when it should be retried.
func (*Service) LinkRoutes ¶
LinkRoutes mounts the short links: the root of the verified short-link domain, and /t/s/{code} on every host. Requests for other hosts at the root fall through to spa.
func (*Service) Message ¶
func (s *Service) Message(ctx context.Context, ws *store.Workspace, id uuid.UUID) (SmsMessageView, error)
Message is one text with its timeline.
func (*Service) MessageOptions ¶
func (s *Service) MessageOptions(ctx context.Context, ws *store.Workspace) ([]SmsMessageOption, error)
MessageOptions lists the messages the route tester can count: recent SMS campaigns and the replies.
func (*Service) MoveScheduled ¶
func (s *Service) MoveScheduled(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, to approvals.ChannelMove) error
MoveScheduled moves a scheduled SMS campaign that hasn't sent a text to another time: the calendar's reschedule (review 2026-11 CA-9). Each queued text gets its new moment in its recipient's zone, inside quiet hours, as a send would have planned it; held texts keep waiting for their sender.
func (*Service) Normalize ¶
Normalize reads a stored webhook into receipts and inbound texts and applies them. A receipt that arrives before its text's id is known is retried (errUnmatched) for a minute, then recorded as unmatched.
func (*Service) Overview ¶
func (s *Service) Overview(ctx context.Context, ws *store.Workspace, p *authz.Principal) (SmsOverview, error)
Overview builds the providers page.
func (*Service) PinSetting ¶
func (s *Service) PinSetting(ctx context.Context, p store.SmsProvider, key, value string) (string, error)
PinSetting keeps a setting an adapter learned from the provider, only while the provider has none (sms.Config.Pin: the SNS topic of webhooks set up by hand, trusted on first use), and returns the value kept: the one another request kept first, if any. Audited when it keeps one.
func (*Service) Prefs ¶
func (s *Service) Prefs(ctx context.Context, ws *store.Workspace, contactID uuid.UUID, code string) (PrefTexts, bool)
Prefs is the contact's texts; false when the workspace doesn't text or the contact has no number.
func (*Service) Preview ¶
func (s *Service) Preview(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in SmsPreviewInput) (SmsPreview, error)
Preview renders the text for a recipient and a country.
func (*Service) PreviewContacts ¶
func (s *Service) PreviewContacts(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) ([]SmsPreviewContact, error)
PreviewContacts lists people to preview as: the first recipients, one per country first, the country with the most recipients leading.
func (*Service) ProviderTest ¶
func (s *Service) ProviderTest(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in SmsProviderTestInput) (SmsMessageView, error)
ProviderTest texts "This is a test from ReputeCast" from the provider's first sender that can text the number's country.
func (*Service) PublicTerms ¶
PublicTerms is what the public page shows; false when the workspace has no SMS provider (the page answers 404).
func (*Service) PublicTermsPage ¶
func (s *Service) PublicTermsPage(ctx context.Context, ws *store.Workspace, lang i18n.Lang, code string) (PublicTermsPage, bool)
PublicTermsPage writes the public page in lang (the pages' language); false when the workspace has no SMS provider (the page answers 404).
func (*Service) PublishTerms ¶
func (s *Service) PublishTerms(ctx context.Context, ws *store.Workspace, p *authz.Principal, in SmsTermsContent) (SmsTerms, error)
PublishTerms publishes a new version of the page. Consent given from now on records this version. Audited.
func (*Service) ReadPrices ¶
ReadPrices reads the price of a segment for every country the provider's senders text.
func (*Service) ReadRegistrations ¶
ReadRegistrations reads the senders' registration statuses from the provider (where its API reports them) and tells people when one was approved or rejected.
func (*Service) RegisterWebhooks ¶
func (s *Service) RegisterWebhooks(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (SmsWebhookSetup, error)
RegisterWebhooks registers the receipt and inbound webhooks again. Audited.
func (*Service) Registration ¶
func (s *Service) Registration(ctx context.Context, ws *store.Workspace, p *authz.Principal, senderID uuid.UUID) (SmsRegistrationPanel, error)
Registration builds a sender's registration panel.
func (*Service) RemoveProvider ¶
func (s *Service) RemoveProvider(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) error
RemoveProvider disconnects a provider: its routes must go first, and queued texts through it are cancelled. Audited.
func (*Service) RemoveSender ¶
func (s *Service) RemoveSender(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) error
RemoveSender removes a sender; routes that use it must change first. Audited.
func (*Service) RemoveSuppression ¶
func (s *Service) RemoveSuppression(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in SmsSuppressionRemove) error
RemoveSuppression takes a number off the SMS suppression list, with a reason. A number that opted out by text stays: only the person can come back, by texting START.
func (*Service) RemoveTestNumber ¶
func (s *Service) RemoveTestNumber(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (SmsRules, error)
RemoveTestNumber removes a test number. Audited.
func (*Service) ReplaceCredentials ¶
func (s *Service) ReplaceCredentials(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in SmsCredentialsInput) error
ReplaceCredentials checks and seals new credentials; held texts go once they work. Audited.
func (*Service) Replies ¶
func (s *Service) Replies(ctx context.Context, ws *store.Workspace, id uuid.UUID, kind string, limit, offset int) (SmsReplyList, error)
Replies lists a campaign's replies by kind: opt_out, help, other or all.
func (*Service) Report ¶
func (s *Service) Report(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (SmsReport, error)
Report builds an SMS campaign's report.
func (*Service) ReportCSV ¶
func (s *Service) ReportCSV(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (*SmsCSV, error)
ReportCSV is the report by country as CSV: each country's sender, texts, delivery, failures, clicks, opt-outs, skipped texts and cost. Counts only, no numbers or names, so it needs what the report needs; the download is logged like other exports.
func (*Service) Review ¶
func (s *Service) Review(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (SmsReview, error)
Review builds Review & send.
func (*Service) RouteTest ¶
func (s *Service) RouteTest(ctx context.Context, ws *store.Workspace, in SmsRouteTestInput) (SmsRouteTest, error)
RouteTest answers "Which sender would text +44 7700 900456?".
func (*Service) Rules ¶
func (s *Service) Rules(ctx context.Context, ws *store.Workspace, p *authz.Principal) (SmsRules, error)
Rules builds Routing & rules.
func (*Service) SavePrefs ¶
func (s *Service) SavePrefs(ctx context.Context, tx pgx.Tx, ws *store.Workspace, contactID uuid.UUID, shown, on []uuid.UUID, code string, ev PrefEvidence) ([]uuid.UUID, error)
SavePrefs records the switches of the lists the page showed, in the caller's transaction. It returns the lists whose opt-in confirmation is to be texted once the transaction commits (SendConfirmation).
func (*Service) SaveRoutes ¶
func (s *Service) SaveRoutes(ctx context.Context, ws *store.Workspace, p *authz.Principal, in SmsRoutesInput) (SmsRules, error)
SaveRoutes replaces the routes: a country in one route only; a fallback must be registered for the route's countries. Audited.
func (*Service) SaveRules ¶
func (s *Service) SaveRules(ctx context.Context, ws *store.Workspace, p *authz.Principal, in SmsRulesInput) (SmsRules, error)
SaveRules saves the rules. The window can be narrowed, never widened past 08:00–21:00; STOP and HELP stay; replies can't be empty. Applies to texts not yet sent. Audited.
func (*Service) SaveSendSettings ¶
func (s *Service) SaveSendSettings(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in SmsSendSettings) (SmsReview, error)
SaveSendSettings stores the schedule, the pending-sender choice and the thresholds. Only times inside the quiet-hours window are accepted.
func (*Service) Send ¶
func (s *Service) Send(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in SmsSendInput) (SmsSendResult, error)
Send schedules a campaign's texts as reviewed: each recipient's text is queued for its moment (quiet hours applied), skipped or held.
func (*Service) SendConfirmation ¶
func (s *Service) SendConfirmation(ctx context.Context, ws *store.Workspace, contactID, listID uuid.UUID)
SendConfirmation queues the opt-in confirmation text: once per number and list, inside the person's window, held when no sender can text their country yet.
func (*Service) SendTest ¶
func (s *Service) SendTest(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in SmsTestInput) ([]SmsTestNumber, error)
SendTest texts the campaign's text to test numbers, each from the sender its country would get. Tests count toward the budget.
func (*Service) SetConsent ¶
func (s *Service) SetConsent(ctx context.Context, q *store.Queries, ws *store.Workspace, contactID uuid.UUID, ph string, listID uuid.UUID, status string, ev Evidence) (bool, error)
SetConsent records a consent change with its evidence, in the caller's transaction; it reports whether an opt-in confirmation should be texted (after the transaction commits, with SendConfirmation). Forms, the preference center, imports and the API all go through it.
func (*Service) SetConsentByTeam ¶
func (s *Service) SetConsentByTeam(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in SmsConsentInput) (SmsContactChannels, error)
SetConsentByTeam changes SMS consent from the profile or the API (subscribers:edit), audited. Consent needs evidence; a text opt-out can't be overridden: only the person can come back, by texting START.
func (*Service) SetPhone ¶
func (s *Service) SetPhone(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in SmsPhoneInput) (SmsContactChannels, error)
SetPhone sets or removes a contact's number, audited. Removing it leaves SMS consent as it is: there's just nothing to text.
func (*Service) SetRegistration ¶
func (s *Service) SetRegistration(ctx context.Context, ws *store.Workspace, p *authz.Principal, senderID uuid.UUID, in SmsRegistrationInput) (SmsRegistrationPanel, error)
SetRegistration records a status the provider doesn't report through its API (Vonage's sender IDs). Texts held for the sender go once it can send. Audited.
func (*Service) SetShortDomain ¶
func (s *Service) SetShortDomain(ctx context.Context, ws *store.Workspace, p *authz.Principal, in SmsShortDomainInput) (SmsRules, error)
SetShortDomain sets (or clears) the short-link domain; it's verified by its CNAME. Audited.
func (*Service) StepEstimate ¶
func (s *Service) StepEstimate(ctx context.Context, ws *store.Workspace, in SmsStepEstimateInput) (SmsStepEstimate, error)
StepEstimate counts an SMS step's text and estimates its cost for the people with SMS consent on its list.
func (*Service) StepStats ¶
func (s *Service) StepStats(ctx context.Context, ws *store.Workspace, automationID uuid.UUID) (SmsStepStatsList, error)
StepStats are a flow's SMS steps' numbers over 30 days.
func (*Service) Suppressions ¶
func (s *Service) Suppressions(ctx context.Context, ws *store.Workspace, p *authz.Principal, f SmsSuppressionFilter) (SmsSuppressionList, error)
Suppressions lists the SMS suppression list.
func (*Service) SyncOptOuts ¶
SyncOptOuts pulls the provider's opt-out list into the SMS suppression list and, for two-way adapters, pushes numbers that opted out here.
func (*Service) Terms ¶
func (s *Service) Terms(ctx context.Context, ws *store.Workspace, p *authz.Principal) (SmsTerms, error)
Terms is the terms page as Forms & pages edits it.
func (*Service) TermsURL ¶
TermsURL is the terms page's address: on the workspace's own domain when it has one.
func (*Service) Unschedule ¶
func (s *Service) Unschedule(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) error
Unschedule takes a scheduled campaign back to a draft: nothing went yet.
func (*Service) Update ¶
func (s *Service) Update(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in SmsCampaignUpdate) (SmsCampaign, error)
Update autosaves the composer: name, text and audience. A text change makes a new version.
func (*Service) UpdateSender ¶
func (s *Service) UpdateSender(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in SmsSenderUpdate) ([]SmsSenderRow, error)
UpdateSender narrows or widens a sender's countries. Audited.
type ShortDomainsArgs ¶
type ShortDomainsArgs struct{}
ShortDomainsArgs checks verified short-link domains again once a day: one that no longer points here, or that another workspace verified first, stops carrying links. Domains waiting for DNS are checked when someone asks ("Check now").
func (ShortDomainsArgs) InsertOpts ¶
func (ShortDomainsArgs) InsertOpts() river.InsertOpts
InsertOpts implements river.JobArgsWithInsertOpts.
type ShortDomainsWorker ¶
type ShortDomainsWorker struct {
river.WorkerDefaults[ShortDomainsArgs]
S *Service
}
ShortDomainsWorker runs ShortDomainsArgs.
func (*ShortDomainsWorker) Timeout ¶
func (w *ShortDomainsWorker) Timeout(*river.Job[ShortDomainsArgs]) time.Duration
Timeout bounds one pass.
func (*ShortDomainsWorker) Work ¶
func (w *ShortDomainsWorker) Work(ctx context.Context, _ *river.Job[ShortDomainsArgs]) error
Work implements river.Worker.
type SignupTexts ¶
type SignupTexts struct{ S *Service }
SignupTexts is texting's side of signup forms (forms.Texts).
func (SignupTexts) Confirm ¶
func (t SignupTexts) Confirm(ctx context.Context, ws *store.Workspace, contactID uuid.UUID, lists []uuid.UUID)
Confirm implements forms.Texts: one opt-in confirmation for the signup, on its first list.
func (SignupTexts) Offer ¶
func (t SignupTexts) Offer(ctx context.Context, ws *store.Workspace, code string) (forms.TextOffer, bool)
Offer implements forms.Texts: nothing when the workspace has no SMS provider. The picker lists the routed countries first and, when every other country has a route too, the rest by name.
func (SignupTexts) Save ¶
func (t SignupTexts) Save(ctx context.Context, tx pgx.Tx, ws *store.Workspace, contactID uuid.UUID, n phone.Number, consent bool, lists []uuid.UUID, ev forms.TextEvidence) (bool, error)
Save implements forms.Texts: the number goes on the contact (the latest one typed wins), and SMS consent on each list with its evidence.
func (SignupTexts) Texted ¶
func (SignupTexts) Texted(code, e164 string) string
Texted implements forms.Texts.
type SmsAudienceRef ¶
type SmsAudienceRef struct {
ID string `json:"id"`
Name string `json:"name"`
Kind string `json:"kind" enum:"list,segment"`
}
SmsAudienceRef is a list or segment in an SMS campaign's audience.
type SmsBudgetView ¶
type SmsBudgetView struct {
Month time.Time `json:"month"`
Budget float64 `json:"budget"`
AlertPct int `json:"alertPct"`
Spent float64 `json:"spent"`
After float64 `json:"after"`
SetBy string `json:"setBy,omitempty"`
SetAt *time.Time `json:"setAt,omitempty"`
}
SmsBudgetView is the month's budget around a send.
type SmsCSV ¶
type SmsCSV struct {
ContentType string `header:"Content-Type"`
ContentDisposition string `header:"Content-Disposition"`
CacheControl string `header:"Cache-Control"`
Body []byte
}
SmsCSV is a CSV download.
type SmsCampaign ¶
type SmsCampaign struct {
ID string `json:"id"`
Name string `json:"name"`
Status string `json:"status" enum:"draft,approval,approved,scheduled,sending,paused,sent,cancelled,failed"`
Version int `json:"version"`
Versions int `json:"versions"`
AutosavedAt *time.Time `json:"autosavedAt,omitempty"`
UpdatedAt time.Time `json:"updatedAt"`
UpdatedBy string `json:"updatedBy"`
CreatedBy string `json:"createdBy"`
// Body is the editable text between the locked parts.
Body string `json:"body"`
Prefix string `json:"prefix"`
OptOut string `json:"optOut"`
// Text is the whole text as written (links not shortened yet).
Text string `json:"text"`
Audience []SmsAudienceRef `json:"audience"`
Funnel SmsFunnel `json:"funnel"`
Routes []SmsRouteLine `json:"routes"`
Counter SmsCounter `json:"counter"`
Links []SmsLinkView `json:"links"`
ShortDomain string `json:"shortDomain"`
ShortDomainStatus string `json:"shortDomainStatus" enum:"none,pending,verified,failed"`
Costs []CountryLine `json:"costs"`
Texts int64 `json:"texts"`
Segments int64 `json:"segments"`
Cost float64 `json:"cost"`
PricedOn *time.Time `json:"pricedOn,omitempty"`
PriceProviders []string `json:"priceProviders"`
Budget SmsBudgetView `json:"budget"`
Tests []SmsTestNumber `json:"tests"`
// Schedule is when it goes out (Review & send sets it).
ScheduleMode string `json:"scheduleMode" enum:"now,at,local"`
SendAt *time.Time `json:"sendAt,omitempty"`
LocalDate string `json:"localDate,omitempty"`
LocalTime string `json:"localTime,omitempty"`
// Arrives is the first local send time, for the preview.
Window string `json:"window"`
RetentionDays int `json:"retentionDays"`
Warnings int `json:"warnings"`
Blocks int `json:"blocks"`
Access SmsCampaignAccess `json:"access"`
Timezone string `json:"timezone"`
}
SmsCampaign is the SMS composer.
type SmsCampaignAccess ¶
type SmsCampaignAccess struct {
CanEdit bool `json:"canEdit"`
// CanSend needs campaigns:send and sms:send; Missing names what the
// viewer lacks, Helpers who can help.
CanSend bool `json:"canSend"`
Missing []string `json:"missing"`
Helpers []string `json:"helpers"`
// CanManageRules is providers:manage (Routing & rules).
CanManageRules bool `json:"canManageRules"`
CanViewContacts bool `json:"canViewContacts"`
}
SmsCampaignAccess is what the viewer may do.
type SmsCampaignCreate ¶
type SmsCampaignCreate struct {
Name string `json:"name" minLength:"1" maxLength:"200"`
Lists []string `json:"lists,omitempty" maxItems:"20"`
Body string `json:"body,omitempty" maxLength:"2000"`
}
SmsCampaignCreate makes an SMS campaign.
type SmsCampaignPath ¶
type SmsCampaignPath struct {
api.WorkspaceInput
CampaignID string `path:"campaignId" format:"uuid" doc:"Campaign id"`
}
SmsCampaignPath names an SMS campaign.
type SmsCampaignUpdate ¶
type SmsCampaignUpdate struct {
Name *string `json:"name,omitempty" maxLength:"200"`
Body *string `json:"body,omitempty" maxLength:"2000"`
Lists *[]string `json:"lists,omitempty" maxItems:"20"`
Segments *[]string `json:"segments,omitempty" maxItems:"20"`
// Version is the version the editor started from: a newer save answers
// 409 version_conflict.
Version int `json:"version" minimum:"1"`
}
SmsCampaignUpdate is an autosave.
type SmsCampaignVersion ¶
type SmsCampaignVersion struct {
Version int `json:"version"`
Body string `json:"body"`
SavedBy string `json:"savedBy"`
SavedAt time.Time `json:"savedAt"`
}
SmsCampaignVersion is a saved version of the text.
type SmsCampaignVersionList ¶
type SmsCampaignVersionList struct {
Items []SmsCampaignVersion `json:"items"`
}
SmsCampaignVersionList is a campaign's versions.
type SmsCatalogItem ¶
type SmsCatalogItem struct {
Adapter string `json:"adapter"`
Name string `json:"name"`
Summary string `json:"summary"`
Badges []sms.Badge `json:"badges"`
Fields []sms.Field `json:"fields"`
Webhooks string `json:"webhooks" enum:"registered,manual"`
Version string `json:"version"`
// Connected counts this workspace's providers of this adapter.
Connected int `json:"connected"`
}
SmsCatalogItem is an SMS adapter in the connect wizard's catalog.
type SmsCatalogList ¶
type SmsCatalogList struct {
Items []SmsCatalogItem `json:"items"`
}
SmsCatalogList is the SMS adapters this build has.
type SmsChannels ¶
type SmsChannels struct {
Channels []channels.ChannelStatus `json:"channels"`
// SwitchShown is true once a second channel is set up; until then the
// header offers "Add a channel".
SwitchShown bool `json:"switchShown"`
}
SmsChannels is the channel switch's state.
type SmsCheck ¶
type SmsCheck struct {
Key string `` /* 139-byte string literal not displayed */
Status string `json:"status" enum:"pass,warn,block"`
// Count is how many recipients it concerns; Total the people it was
// counted from.
Count int64 `json:"count"`
Total int64 `json:"total"`
// Countries and Sender: the recipients' countries and the sender
// concerned (registration and routes).
Countries []string `json:"countries"`
Sender string `json:"sender,omitempty"`
Provider string `json:"provider,omitempty"`
// Registration is the sender's status there; Since its date.
Registration string `json:"registration,omitempty"`
Since *time.Time `json:"since,omitempty"`
// Senders are the registered senders, for the passing check.
Senders []SmsCheckSender `json:"senders"`
Lists []string `json:"lists"`
// Reasons counts suppressions by reason (landline, invalid…).
Reasons map[string]int64 `json:"reasons"`
// Text is the opt-out text or the brand prefix it found.
Text string `json:"text,omitempty"`
// Characters, Segments and Encoding: the length check's.
Characters int `json:"characters"`
Segments int `json:"segments"`
Encoding string `json:"encoding,omitempty"`
// Links counts the links; Domain is the short-link domain; Shorteners
// the public shorteners found.
Links int `json:"links"`
Domain string `json:"domain,omitempty"`
VerifiedOn *time.Time `json:"verifiedOn,omitempty"`
Shorteners []string `json:"shorteners"`
// Window is the quiet-hours window; Local the local send time.
Window string `json:"window,omitempty"`
Local string `json:"local,omitempty"`
// Cost, Remaining, Spent, After and Budget are the budget check's.
Cost float64 `json:"cost"`
Remaining float64 `json:"remaining"`
Spent float64 `json:"spent"`
After float64 `json:"after"`
Budget float64 `json:"budget"`
AlertPct int `json:"alertPct"`
// ByArea and ByCountry split the assumed time zones (area code, the
// country's main zone).
ByArea int64 `json:"byArea"`
ByCountry int64 `json:"byCountry"`
// Choice is the registration warning's fix in force: skip or wait.
Choice string `json:"choice,omitempty" enum:"skip,wait,"`
// ClearedBy and ClearedAt: who emptied the opt-out text, and when.
ClearedBy string `json:"clearedBy,omitempty"`
ClearedAt *time.Time `json:"clearedAt,omitempty"`
}
SmsCheck is one check of Review & send for SMS. The app words it from its facts.
type SmsCheckSender ¶
type SmsCheckSender struct {
Sender string `json:"sender"`
Registration string `json:"registration"`
Since *time.Time `json:"since,omitempty"`
Countries []string `json:"countries"`
}
SmsCheckSender is a sender in the passing registration check.
type SmsClickLink ¶
type SmsClickLink struct {
URL string `json:"url"`
Domain string `json:"domain"`
People int64 `json:"people"`
Machine int64 `json:"machine"`
}
SmsClickLink is a link with its clicks.
type SmsConnectInput ¶
type SmsConnectInput struct {
Adapter string `json:"adapter" minLength:"1"`
Name string `json:"name,omitempty" maxLength:"60"`
// Fields are the connection form's values, by key; secret ones are
// sealed and never returned.
Fields map[string]string `json:"fields"`
// SetupID is the wizard's setup, when it started one.
SetupID string `json:"setupId,omitempty"`
}
SmsConnectInput connects an SMS provider: the wizard's second step.
type SmsConnectResult ¶
type SmsConnectResult struct {
ProviderID string `json:"providerId"`
SetupID string `json:"setupId"`
Account sms.Account `json:"account"`
Webhooks SmsWebhookSetup `json:"webhooks"`
Senders []SmsFoundSender `json:"senders"`
}
SmsConnectResult is the wizard after the connection step.
type SmsConsentEvent ¶
type SmsConsentEvent struct {
ID string `json:"id"`
At time.Time `json:"at"`
Action string `` /* 128-byte string literal not displayed */
List string `json:"list,omitempty"`
Number string `json:"number"`
Source string `json:"source"`
Page string `json:"page,omitempty"`
ConsentText string `json:"consentText,omitempty"`
ConsentVersion string `json:"consentVersion,omitempty"`
Keyword string `json:"keyword,omitempty"`
IP string `json:"ip,omitempty"`
Actor string `json:"actor,omitempty"`
Note string `json:"note,omitempty"`
}
SmsConsentEvent is one change of SMS consent, with its evidence.
type SmsConsentEvidence ¶
type SmsConsentEvidence struct {
Source string `json:"source" minLength:"1" maxLength:"200" doc:"Where consent was given: a form, an event, a call."`
Page string `json:"page,omitempty" maxLength:"500"`
ConsentText string `json:"consentText" minLength:"1" maxLength:"1000" doc:"The exact text the person agreed to."`
ConsentVersion string `json:"consentVersion,omitempty" maxLength:"40"`
IP string `json:"ip,omitempty" maxLength:"45"`
At time.Time `json:"at" doc:"When consent was given."`
}
SmsConsentEvidence is the evidence the API asks for: the exact consent text, where it was given and when.
type SmsConsentInput ¶
type SmsConsentInput struct {
ListID string `json:"listId" format:"uuid"`
Status string `json:"status" enum:"subscribed,not_subscribed"`
Evidence *SmsConsentEvidence `json:"evidence,omitempty"`
Note string `json:"note,omitempty" maxLength:"500"`
}
SmsConsentInput changes a contact's SMS consent on a list. Giving consent needs its evidence.
type SmsContactChannels ¶
type SmsContactChannels struct {
Phone string `json:"phone"`
Display string `json:"display"`
Country string `json:"country"`
LineType string `json:"lineType" enum:"mobile,landline,toll_free,voip,unknown,"`
LineSource string `json:"lineSource" enum:"number_plan,provider,receipt,"`
TimeZone string `json:"timeZone"`
ZoneSource string `json:"zoneSource" enum:"contact,area_code,country,unknown"`
// Shared counts the other contacts with the same number: a STOP from it
// applies to all of them.
Suppressed *SmsSuppression `json:"suppressed,omitempty"`
Lists []SmsContactList `json:"lists"`
Events []SmsConsentEvent `json:"events"`
CanEdit bool `json:"canEdit"`
// SMSSetUp is false until an SMS provider is connected.
SMSSetUp bool `json:"smsSetUp"`
// WhatsAppSetUp is true once WhatsApp is connected: the card shows its
// column then, or while a list still has WhatsApp consent.
WhatsAppSetUp bool `json:"whatsAppSetUp"`
}
SmsContactChannels is a contact's phone and consent per list per channel.
type SmsContactList ¶
type SmsContactList struct {
ListID string `json:"listId"`
Name string `json:"name"`
// Email is the email consent: subscribed, pending, unsubscribed or
// not_subscribed.
Email string `json:"email" enum:"subscribed,pending,unsubscribed,not_subscribed"`
EmailAt *time.Time `json:"emailAt,omitempty"`
EmailSource string `json:"emailSource,omitempty"`
// EmailSourceLabel names the source ("Brevo import", "preference center").
EmailSourceLabel string `json:"emailSourceLabel,omitempty"`
// EmailConfirmed is true once the person confirmed: a double opt-in, or
// a list added in the preference center (as the profile's card says).
EmailConfirmed bool `json:"emailConfirmed,omitempty"`
SMS string `json:"sms" enum:"subscribed,pending,opted_out,not_subscribed"`
SMSAt *time.Time `json:"smsAt,omitempty"`
SMSSource string `json:"smsSource,omitempty"`
SMSPage string `json:"smsPage,omitempty"`
SMSVersion string `json:"smsVersion,omitempty"`
SMSIP string `json:"smsIp,omitempty"`
SMSKeyword string `json:"smsKeyword,omitempty"`
// Confirmation is the opt-in confirmation text's status, when one went.
Confirmation string `json:"confirmation,omitempty"`
ConfirmationAt *time.Time `json:"confirmationAt,omitempty"`
// WhatsApp is the WhatsApp consent (X22), kept per list like SMS, with
// its latest evidence: the page and the consent text's version, or the
// keyword of an opt-out.
WhatsApp string `json:"whatsApp" enum:"subscribed,pending,opted_out,not_subscribed"`
WhatsAppAt *time.Time `json:"whatsAppAt,omitempty"`
WhatsAppSource string `json:"whatsAppSource,omitempty"`
WhatsAppPage string `json:"whatsAppPage,omitempty"`
WhatsAppVersion string `json:"whatsAppVersion,omitempty"`
WhatsAppKeyword string `json:"whatsAppKeyword,omitempty"`
}
SmsContactList is a list's consent on each channel.
type SmsContactPath ¶
type SmsContactPath struct {
api.WorkspaceInput
ContactID string `path:"contactId" format:"uuid" doc:"Contact id"`
}
SmsContactPath names a contact.
type SmsCounter ¶
type SmsCounter struct {
sms.Count
// Base is the length without the personalized parts.
Base int `json:"base"`
// Fields are the contact fields that change the length.
Fields []SmsField `json:"fields"`
// Spread is how many recipients get each number of segments, when
// fields change the length.
Spread []SmsSpread `json:"spread"`
// Longest is the longest personalized text: whose and how long.
Longest *SmsLongest `json:"longest,omitempty"`
}
SmsCounter is the segment counter.
type SmsCountryReport ¶
type SmsCountryReport struct {
Country string `json:"country"`
Sender string `json:"sender"`
Sent int64 `json:"sent"`
Delivered int64 `json:"delivered"`
DeliveredPct float64 `json:"deliveredPct"`
Failed int64 `json:"failed"`
Clicks int64 `json:"clicks"`
ClickPct float64 `json:"clickPct"`
OptOuts int64 `json:"optOuts"`
Cost float64 `json:"cost"`
Skipped int64 `json:"skipped"`
SkipReason string `json:"skipReason,omitempty"`
}
SmsCountryReport is a country's line.
type SmsCredentialsInput ¶
SmsCredentialsInput replaces a provider's credentials.
type SmsEvent ¶
type SmsEvent struct {
ID string `json:"id"`
At time.Time `json:"at"`
Provider string `json:"provider"`
Adapter string `json:"adapter"`
// Raw is the raw event as the provider sent it, summed up
// ("MessageStatus=delivered").
Raw string `json:"raw"`
Kind string `json:"kind" enum:"receipt,inbound,test,other"`
// Normalized is what ReputeCast made of it: queued, sent, delivered,
// undelivered, failed, opted_out, opted_in, help, yes, reply, or
// unmatched; pending while it waits for its job.
Normalized string `json:"normalized"`
// Reason, Code and the facts the detail is worded from.
Reason string `json:"reason,omitempty"`
Code string `json:"code,omitempty"`
Temporary bool `json:"temporary"`
Suppressed bool `json:"suppressed"`
Filtered int64 `json:"filtered"`
Keyword string `json:"keyword,omitempty"`
Lists []string `json:"lists"`
Replied bool `json:"replied"`
ProviderAnswered bool `json:"providerAnswered"`
SignatureOK bool `json:"signatureOk"`
MessageRef string `json:"messageRef,omitempty"`
Number string `json:"number"`
Source string `json:"source"`
Error string `json:"error,omitempty"`
}
SmsEvent is one raw provider event beside its normalized one.
type SmsEventFilter ¶
SmsEventFilter filters the Events tab: receipts, keywords, replies or failures, and a provider.
type SmsEventList ¶
type SmsEventList struct {
Items []SmsEvent `json:"items"`
Total int64 `json:"total"`
ThisMonth int64 `json:"thisMonth"`
Month time.Time `json:"month"`
Page int `json:"page"`
PageSize int `json:"pageSize"`
Providers []SmsSuppressionProvider `json:"providers"`
OptOutSync []SmsOptOutSyncRow `json:"optOutSync"`
Suppressed int64 `json:"suppressed"`
}
SmsEventList is the Events tab.
type SmsFailureCode ¶
type SmsFailureCode struct {
Provider string `json:"provider"`
Code string `json:"code"`
Count int64 `json:"count"`
}
SmsFailureCode is a provider's code and how often it came.
type SmsFailureReason ¶
type SmsFailureReason struct {
Reason string `json:"reason"`
Count int64 `json:"count"`
Codes []SmsFailureCode `json:"codes"`
// Rate and Limit: the share of texts with a receipt, against the
// auto-pause threshold it counts toward.
Rate float64 `json:"rate"`
Limit float64 `json:"limit"`
}
SmsFailureReason is a failure reason with the providers' own codes.
type SmsField ¶
type SmsField struct {
Key string `json:"key"`
Fallback string `json:"fallback"`
HasFallback bool `json:"hasFallback"`
}
SmsField is a personalization field in the text.
type SmsFoundSender ¶
type SmsFoundSender struct {
Kind string `json:"kind" enum:"toll_free,10dlc,local,mobile,sender_id"`
Value string `json:"value"`
Label string `json:"label"`
Countries []string `json:"countries"`
Throughput float64 `json:"throughput"`
ProviderRef string `json:"providerRef"`
Registration SmsRegistrationView `json:"registration"`
Imported bool `json:"imported"`
}
SmsFoundSender is a number found in the account.
type SmsFoundSenderList ¶
type SmsFoundSenderList struct {
Items []SmsFoundSender `json:"items"`
}
SmsFoundSenderList is the numbers in a provider's account.
type SmsFunnel ¶
type SmsFunnel struct {
Base int64 `json:"base"`
NoConsent int64 `json:"noConsent"`
Suppressed int64 `json:"suppressed"`
Reasons map[string]int64 `json:"reasons"`
CanReceive int64 `json:"canReceive"`
// Skipped are recipients who can receive texts but get nothing from
// this campaign: their country's sender is pending or has no route.
Skipped int64 `json:"skipped"`
SkippedIn []string `json:"skippedIn"`
ToSend int64 `json:"toSend"`
Assumed int64 `json:"assumed"`
}
SmsFunnel is how the audience narrows to who gets texts.
type SmsHeld ¶
type SmsHeld struct {
Skipped int64 `json:"skipped"`
SkippedCountries []string `json:"skippedCountries"`
SkipReason string `json:"skipReason,omitempty"`
SkipSender string `json:"skipSender,omitempty"`
QuietHours int64 `json:"quietHours"`
NoConsent int64 `json:"noConsent"`
Suppressed int64 `json:"suppressed"`
Lists []string `json:"lists"`
// NotSent counts texts cancelled while held (a provider down past the
// window, a cancelled send), by reason.
NotSent map[string]int64 `json:"notSent"`
}
SmsHeld is who got nothing and why.
type SmsIDPath ¶
type SmsIDPath struct {
api.WorkspaceInput
ID string `path:"id" format:"uuid"`
}
SmsIDPath names a row by id.
type SmsImportInput ¶
type SmsImportInput struct {
Senders []SmsImportSender `json:"senders" minItems:"1" maxItems:"50"`
SetupID string `json:"setupId,omitempty"`
}
SmsImportInput imports numbers found in the account.
type SmsImportSender ¶
type SmsImportSender struct {
Value string `json:"value" minLength:"1"`
Countries []string `json:"countries,omitempty" maxItems:"60"`
}
SmsImportSender is one number to import, with its countries.
type SmsLarge ¶
type SmsLarge struct {
Recipients int64 `json:"recipients"`
Cost float64 `json:"cost"`
Required bool `json:"required"`
}
SmsLarge is the typed-confirmation rule.
type SmsLinkView ¶
type SmsLinkView struct {
URL string `json:"url"`
Host string `json:"host"`
Shortener bool `json:"shortener"`
// Length is what it counts once shortened (17 on go.acme.io).
Length int `json:"length"`
UTMCampaign string `json:"utmCampaign"`
}
SmsLinkView is a link of the text.
type SmsLongest ¶
type SmsLongest struct {
Name string `json:"name"`
Value string `json:"value"`
Characters int `json:"characters"`
Segments int `json:"segments"`
// LongFields counts recipients whose field pushes them past one segment.
Recipients int64 `json:"recipients"`
Cost float64 `json:"cost"`
}
SmsLongest is the recipient with the longest personalized text.
type SmsMemberOption ¶
type SmsMemberOption struct {
UserID string `json:"userId"`
Name string `json:"name"`
Role string `json:"role"`
Color string `json:"color"`
}
SmsMemberOption is a member who can get test texts.
type SmsMessageEvent ¶
type SmsMessageEvent struct {
Kind string `json:"kind"`
Code string `json:"code,omitempty"`
At time.Time `json:"at"`
}
SmsMessageEvent is one step of a text's timeline.
type SmsMessageOption ¶
type SmsMessageOption struct {
Key string `json:"key"`
Name string `json:"name"`
Segments int `json:"segments"`
}
SmsMessageOption is a message the tester can count.
type SmsMessageOptionList ¶
type SmsMessageOptionList struct {
Items []SmsMessageOption `json:"items"`
}
SmsMessageOptionList is what the route tester can count.
type SmsMessageView ¶
type SmsMessageView struct {
ID string `json:"id"`
Kind string `json:"kind"`
Status string `json:"status" enum:"queued,held,skipped,sending,sent,delivered,undelivered,failed,cancelled"`
Reason string `json:"reason,omitempty"`
Recipient string `json:"recipient"`
Sender string `json:"sender"`
Provider string `json:"provider"`
Body string `json:"body"`
Characters int `json:"characters"`
Segments int `json:"segments"`
Encoding string `json:"encoding"`
ProviderMessageID string `json:"providerMessageId,omitempty"`
CreatedAt time.Time `json:"createdAt"`
SentAt *time.Time `json:"sentAt,omitempty"`
DeliveredAt *time.Time `json:"deliveredAt,omitempty"`
Seconds *float64 `json:"seconds,omitempty"`
Events []SmsMessageEvent `json:"events"`
}
SmsMessageView is one text with its timeline: the wizard's test, a contact's text.
type SmsOptOutSyncRow ¶
type SmsOptOutSyncRow struct {
Provider string `json:"provider"`
Adapter string `json:"adapter"`
Mode string `json:"mode" enum:"two_way,read_only,off"`
Pulled int64 `json:"pulled"`
Pushed int64 `json:"pushed"`
LastSyncAt *time.Time `json:"lastSyncAt,omitempty"`
Status string `json:"status" enum:"in_sync,failing"`
Detail string `json:"detail,omitempty"`
}
SmsOptOutSyncRow is a provider's opt-out sync.
type SmsOutageView ¶
type SmsOutageView struct {
Provider string `json:"provider"`
ProviderID string `json:"providerId"`
Status string `json:"status"`
Since *time.Time `json:"since,omitempty"`
Answer string `json:"answer,omitempty"`
Failures int `json:"failures"`
Held int64 `json:"held"`
Countries []string `json:"countries"`
HasFallback bool `json:"hasFallback"`
LastAccepted *time.Time `json:"lastAccepted,omitempty"`
NextTry *time.Time `json:"nextTry,omitempty"`
Told []string `json:"told"`
}
SmsOutageView is a provider outage holding the send's texts.
type SmsOverview ¶
type SmsOverview struct {
Tiles SmsOverviewTiles `json:"tiles"`
Providers []SmsProviderCard `json:"providers"`
NotConnected []SmsCatalogItem `json:"notConnected"`
Senders []SmsSenderRow `json:"senders"`
Routes []SmsRouteSummary `json:"routes"`
// Other is "every other country": dont_send or route.
Other string `json:"other" enum:"dont_send,route"`
OtherSender string `json:"otherSender,omitempty"`
CheckedAt *time.Time `json:"checkedAt,omitempty"`
CanManage bool `json:"canManage"`
Helpers []string `json:"helpers"`
Timezone string `json:"timezone"`
}
SmsOverview is Sending providers › SMS › Providers.
type SmsOverviewTiles ¶
type SmsOverviewTiles struct {
Month time.Time `json:"month"`
Sent int64 `json:"sent"`
// ByKind counts this month's texts: campaign, automation, confirmation,
// test, reply.
ByKind map[string]int64 `json:"byKind"`
Delivered int64 `json:"delivered"`
Failed int64 `json:"failed"`
DeliveredPct float64 `json:"deliveredPct"`
Spend float64 `json:"spend"`
Budget float64 `json:"budget"`
AlertPct int `json:"alertPct"`
// SpendBy is each provider's share of the month's spend.
SpendBy []SmsProviderSpend `json:"spendBy"`
Suppressed int64 `json:"suppressed"`
// SuppressedBy counts the list by reason.
SuppressedBy map[string]int64 `json:"suppressedBy"`
// BudgetHeld counts the texts waiting for the budget to be raised.
BudgetHeld int64 `json:"budgetHeld"`
}
SmsOverviewTiles are the tiles above the provider cards.
type SmsPageCheck ¶
type SmsPageCheck struct {
URL string `json:"url"`
Status int `json:"status"`
At *time.Time `json:"at,omitempty"`
}
SmsPageCheck is a page carriers check, and how it answered.
type SmsPauseView ¶
type SmsPauseView struct {
Kind string `json:"kind" enum:"auto,person,outage,budget"`
At *time.Time `json:"at,omitempty"`
By string `json:"by,omitempty"`
Metric string `json:"metric,omitempty" enum:"failed,filtered,opt_outs,"`
Value float64 `json:"value"`
Limit float64 `json:"limit"`
Events int64 `json:"events"`
Base int64 `json:"base"`
Code string `json:"code,omitempty"`
Provider string `json:"provider,omitempty"`
CodeCount int64 `json:"codeCount"`
Held int64 `json:"held"`
}
SmsPauseView is why a send is paused.
type SmsPhoneInput ¶
type SmsPhoneInput struct {
// Phone in any common format; empty removes it.
Phone string `json:"phone" maxLength:"40"`
// Country is used when the number has no country code.
Country string `json:"country,omitempty" pattern:"^[A-Z]{2}$"`
}
SmsPhoneInput sets a contact's number.
type SmsPreview ¶
type SmsPreview struct {
Sender string `json:"sender"`
SenderKind string `json:"senderKind"`
Provider string `json:"provider"`
CanReply bool `json:"canReply"`
Country string `json:"country"`
Contact string `json:"contact"`
ContactID string `json:"contactId,omitempty"`
Parts []SmsPreviewPart `json:"parts"`
Characters int `json:"characters"`
Segments int `json:"segments"`
Encoding string `json:"encoding"`
Price float64 `json:"price"`
// Skipped is why this country gets nothing (pending, no_route…).
Skipped string `json:"skipped,omitempty"`
// Arrives is when the person gets it (the campaign's schedule in their
// zone); Zone is their time zone.
Arrives *time.Time `json:"arrives,omitempty"`
Zone string `json:"zone"`
// Confirmation is the opt-in confirmation the person got before, for
// the thread.
Confirmation *SmsPreviewBubble `json:"confirmation,omitempty"`
}
SmsPreview is the phone preview.
type SmsPreviewBubble ¶
SmsPreviewBubble is an earlier text in the thread.
type SmsPreviewContact ¶
type SmsPreviewContact struct {
ID string `json:"id"`
Name string `json:"name"`
Country string `json:"country"`
}
SmsPreviewContact is someone to preview as.
type SmsPreviewContactList ¶
type SmsPreviewContactList struct {
Items []SmsPreviewContact `json:"items"`
}
SmsPreviewContactList is who the preview can be shown as.
type SmsPreviewInput ¶
type SmsPreviewInput struct {
ContactID string `json:"contactId,omitempty" format:"uuid"`
// Country shows the sender as that country sees it.
Country string `json:"country,omitempty" pattern:"^[A-Z]{2}$"`
}
SmsPreviewInput asks for the phone preview.
type SmsPreviewPart ¶
type SmsPreviewPart struct {
Kind string `json:"kind" enum:"fixed,text,link"`
Text string `json:"text"`
}
SmsPreviewPart is a piece of the bubble: a locked part, text or a link.
type SmsProviderCard ¶
type SmsProviderCard struct {
ID string `json:"id"`
Adapter string `json:"adapter"`
Name string `json:"name"`
Status string `json:"status" enum:"healthy,degraded,down,credentials_rejected"`
// Detail qualifies Degraded: receipts_silent.
Detail string `json:"detail,omitempty"`
Since *time.Time `json:"since,omitempty"`
AccountLabel string `json:"accountLabel"`
Live bool `json:"live"`
// TestMode is true when the adapter has test credentials: the card then
// says whether these are live.
TestMode bool `json:"testMode"`
AccountHint string `json:"accountHint"`
// SecretLabel names the secret fields kept ("API key", "signature
// secret"); they're never shown.
SecretLabels []string `json:"secretLabels"`
// Countries are the routes it serves; Held the countries whose route
// it holds (a pending registration).
Countries []string `json:"countries"`
Held []string `json:"held"`
// Senders sums up its senders.
SenderKinds []string `json:"senderKinds"`
SenderCount int `json:"senderCount"`
// SenderIDs and SenderIDCountries: its alphanumeric sender IDs.
SenderIDs []string `json:"senderIds"`
SenderIDCountries int `json:"senderIdCountries"`
Webhooks string `json:"webhooks" enum:"registered,manual"`
WebhookURL string `json:"webhookUrl"`
ConnectedAt time.Time `json:"connectedAt"`
ConnectedBy string `json:"connectedBy"`
LastReceiptAt *time.Time `json:"lastReceiptAt,omitempty"`
LastCheckedAt *time.Time `json:"lastCheckedAt,omitempty"`
FailedPct float64 `json:"failedPct"`
FilteredPct float64 `json:"filteredPct"`
PauseFailed float64 `json:"pauseFailed"`
PauseFiltered float64 `json:"pauseFiltered"`
Spend float64 `json:"spend"`
PriceMin float64 `json:"priceMin"`
PriceMax float64 `json:"priceMax"`
PriceCountries []string `json:"priceCountries"`
Badges []sms.Badge `json:"badges"`
Demo bool `json:"demo"`
// Answer is the provider's answer to the last failed call; Held the
// texts waiting for it; SentSince and ReceiptsSince the texts and
// receipts since receipts went silent.
Answer string `json:"answer,omitempty"`
HeldTexts int64 `json:"heldTexts"`
SentSince int64 `json:"sentSince"`
ReceiptsSince int64 `json:"receiptsSince"`
Told []string `json:"told"`
Console string `json:"console"`
OptOutSync string `json:"optOutSync" enum:"two_way,read_only,off"`
}
SmsProviderCard is a connected provider.
type SmsProviderCount ¶
SmsProviderCount is a provider's share of the texts.
type SmsProviderPath ¶
type SmsProviderPath struct {
api.WorkspaceInput
ProviderID string `path:"providerId" format:"uuid" doc:"SMS provider id"`
}
SmsProviderPath names an SMS provider.
type SmsProviderSpend ¶
SmsProviderSpend is a provider's spend this month.
type SmsProviderTestInput ¶
type SmsProviderTestInput struct {
// TestNumberID is a test number; Phone a member's number typed here.
TestNumberID string `json:"testNumberId,omitempty"`
Phone string `json:"phone,omitempty" maxLength:"40"`
SetupID string `json:"setupId,omitempty"`
}
SmsProviderTestInput sends the wizard's test text to a member's phone.
type SmsRegistrationHelper ¶
type SmsRegistrationHelper struct {
OptIn string `json:"optIn"`
Samples []string `json:"samples"`
HelpReply string `json:"helpReply"`
OptOutReply string `json:"optOutReply"`
TermsURL string `json:"termsUrl"`
}
SmsRegistrationHelper is what the provider's form asks for.
type SmsRegistrationInput ¶
type SmsRegistrationInput struct {
Kind string `json:"kind" enum:"toll_free,brand,campaign,sender_id"`
Country string `json:"country,omitempty" pattern:"^([A-Z]{2})?$"`
Name string `json:"name,omitempty" maxLength:"120"`
Status string `json:"status" enum:"not_registered,pending,verified,approved,rejected,allowed,not_supported"`
Reason string `json:"reason,omitempty" maxLength:"500"`
On time.Time `json:"on" doc:"The day the provider gave this status."`
}
SmsRegistrationInput sets a registration status by hand, with its date.
type SmsRegistrationPanel ¶
type SmsRegistrationPanel struct {
Sender SmsSenderRow `json:"sender"`
Items []SmsRegistrationView `json:"items"`
Helper SmsRegistrationHelper `json:"helper"`
Console string `json:"console"`
ReadFrom bool `json:"readFrom"`
ReadAt *time.Time `json:"readAt,omitempty"`
// Details are what was submitted, where the provider reports them.
Details map[string]string `json:"details"`
// Skipped counts the recipients the pending registration leaves out
// of the campaigns being written; Held the confirmations waiting.
Held int64 `json:"held"`
// Checks are the pages carriers look at, checked by ReputeCast.
Checks []SmsPageCheck `json:"checks"`
CanManage bool `json:"canManage"`
}
SmsRegistrationPanel is a sender's registration panel: every status, what the provider's form asks for, and where to register.
type SmsRegistrationView ¶
type SmsRegistrationView struct {
Kind string `json:"kind" enum:"toll_free,brand,campaign,sender_id,"`
Country string `json:"country"`
Name string `json:"name,omitempty"`
Status string `json:"status" enum:"not_registered,pending,verified,approved,rejected,allowed,not_supported"`
Reason string `json:"reason,omitempty"`
Since *time.Time `json:"since,omitempty"`
// Source is where the status comes from: api (read from the provider),
// manual (set by hand) or rule (sender IDs in the US and Canada).
Source string `json:"source" enum:"api,manual,rule,"`
SetBy string `json:"setBy,omitempty"`
ReadAt *time.Time `json:"readAt,omitempty"`
}
SmsRegistrationView is a sender's registration in one country (or for all of its countries).
type SmsReply ¶
type SmsReply struct {
ID string `json:"id"`
At time.Time `json:"at"`
Contact string `json:"contact"`
ContactID string `json:"contactId,omitempty"`
Number string `json:"number"`
Body string `json:"body"`
Kind string `json:"kind" enum:"opt_out,opt_in,help,yes,reply"`
Keyword string `json:"keyword,omitempty"`
Lists []string `json:"lists"`
Replied bool `json:"replied"`
ReplyChars int `json:"replyChars"`
ReplySegments int `json:"replySegments"`
// Zone is the person's time zone, for "Chicago local".
Zone string `json:"zone"`
// AnyCase is true when the keyword matched in another case ("Stop").
AnyCase bool `json:"anyCase"`
}
SmsReply is a reply to the campaign.
type SmsReplyList ¶
type SmsReplyList struct {
Items []SmsReply `json:"items"`
Counts map[string]int64 `json:"counts"`
}
SmsReplyList is a page of a campaign's replies.
type SmsReplyView ¶
SmsReplyView is a keyword reply with its length.
type SmsReport ¶
type SmsReport struct {
CampaignID string `json:"campaignId"`
Name string `json:"name"`
Status string `json:"status"`
Phase string `json:"phase" enum:"scheduled,sending,paused,completed,cancelled,"`
ScheduleMode string `json:"scheduleMode" enum:"now,at,local"`
LocalTime string `json:"localTime,omitempty"`
ScheduledAt *time.Time `json:"scheduledAt,omitempty"`
StartedAt *time.Time `json:"startedAt,omitempty"`
CompletedAt *time.Time `json:"completedAt,omitempty"`
Window string `json:"window"`
Recipients int64 `json:"recipients"`
Tiles SmsReportTiles `json:"tiles"`
Points []SmsTimePoint `json:"points"`
Steps []SmsZoneStep `json:"steps"`
Senders []SmsSenderReport `json:"senders"`
// ReceiptsWithin is the slowest receipt, in seconds.
ReceiptsWithin float64 `json:"receiptsWithin"`
Countries []SmsCountryReport `json:"countries"`
Failures []SmsFailureReason `json:"failures"`
Links []SmsClickLink `json:"links"`
Replies []SmsReply `json:"replies"`
ReplyCounts map[string]int64 `json:"replyCounts"`
Held SmsHeld `json:"held"`
Pause *SmsPauseView `json:"pause,omitempty"`
Outage *SmsOutageView `json:"outage,omitempty"`
Sample *SmsTimelineSample `json:"sample,omitempty"`
ShortDomain string `json:"shortDomain"`
CanPause bool `json:"canPause"`
CanResume bool `json:"canResume"`
Helpers []string `json:"helpers"`
Timezone string `json:"timezone"`
}
SmsReport is an SMS campaign's report.
type SmsReportTiles ¶
type SmsReportTiles struct {
Sent int64 `json:"sent"`
ByProvider []SmsProviderCount `json:"byProvider"`
Skipped int64 `json:"skipped"`
Delivered int64 `json:"delivered"`
DeliveredPct float64 `json:"deliveredPct"`
// Waiting are texts sent with no receipt yet.
Waiting int64 `json:"waiting"`
Failed int64 `json:"failed"`
FailedBy map[string]int64 `json:"failedBy"`
Clicks int64 `json:"clicks"`
ClickPct float64 `json:"clickPct"`
Machine int64 `json:"machine"`
OptOuts int64 `json:"optOuts"`
OptOutPct float64 `json:"optOutPct"`
// OptOutsByKeyword is true when every opt-out was a reply (STOP).
OptOutsByKeyword bool `json:"optOutsByKeyword"`
Cost float64 `json:"cost"`
PerText float64 `json:"perText"`
// Planned is the whole send's cost (while it runs).
Planned float64 `json:"planned"`
WithinBudget bool `json:"withinBudget"`
// Queued are texts waiting for their time; Held ones held (pause,
// outage, quiet hours).
Queued int64 `json:"queued"`
Held int64 `json:"held"`
}
SmsReportTiles are the report's tiles.
type SmsReview ¶
type SmsReview struct {
Campaign SmsReviewCampaign `json:"campaign"`
Verdict string `json:"verdict" enum:"ready,warnings,blocked"`
Passed int `json:"passed"`
Warnings int `json:"warnings"`
Blocks int `json:"blocks"`
CheckedAt time.Time `json:"checkedAt"`
Checks []SmsCheck `json:"checks"`
Funnel SmsFunnel `json:"funnel"`
Lists []string `json:"lists"`
Routes []SmsReviewRoute `json:"routes"`
Costs []CountryLine `json:"costs"`
Texts int64 `json:"texts"`
Segments int64 `json:"segments"`
SegmentsEach int `json:"segmentsEach"`
Cost float64 `json:"cost"`
PricedOn *time.Time `json:"pricedOn,omitempty"`
Budget SmsBudgetView `json:"budget"`
Schedule SmsSchedule `json:"schedule"`
PendingPolicy string `json:"pendingPolicy" enum:"skip,wait"`
Thresholds SmsThresholds `json:"thresholds"`
Defaults SmsThresholds `json:"defaults"`
Tests []SmsTestNumber `json:"tests"`
Approval approvals.ReviewApproval `json:"approval"`
Policy SmsReviewPolicy `json:"policy"`
Access SmsCampaignAccess `json:"access"`
Large SmsLarge `json:"large"`
Fingerprint string `json:"fingerprint"`
Send *SmsSendView `json:"send,omitempty"`
Preview SmsPreview `json:"preview"`
Timezone string `json:"timezone"`
}
SmsReview is Review & send for an SMS campaign.
type SmsReviewCampaign ¶
type SmsReviewCampaign struct {
ID string `json:"id"`
Name string `json:"name"`
Status string `json:"status" enum:"draft,approval,approved,scheduled,sending,paused,sent,cancelled,failed"`
Version int `json:"version"`
AutosavedAt *time.Time `json:"autosavedAt,omitempty"`
UpdatedBy string `json:"updatedBy"`
Text string `json:"text"`
}
SmsReviewCampaign is the campaign as Review & send shows it.
type SmsReviewPolicy ¶
type SmsReviewPolicy struct {
AudienceMin int64 `json:"audienceMin"`
AudienceRule bool `json:"audienceRule"`
CostRule bool `json:"costRule"`
CostAmount float64 `json:"costAmount"`
AuthorLacksSend bool `json:"authorLacksSend"`
}
SmsReviewPolicy is what the approval note quotes.
type SmsReviewRoute ¶
type SmsReviewRoute struct {
Provider string `json:"provider"`
Adapter string `json:"adapter"`
Sender string `json:"sender"`
Recipients int64 `json:"recipients"`
Rate float64 `json:"rate"`
Cost float64 `json:"cost"`
// Seconds is how long its texts take at its throughput.
Seconds float64 `json:"seconds"`
}
SmsReviewRoute is a provider's share of the send.
type SmsRouteGap ¶
type SmsRouteGap struct {
Countries []string `json:"countries"`
Sender string `json:"sender"`
Status string `json:"status"`
Since *time.Time `json:"since,omitempty"`
People int64 `json:"people"`
// Held counts the opt-in confirmations waiting for it.
Held int64 `json:"held"`
}
SmsRouteGap is a country whose route can't send.
type SmsRouteInput ¶
type SmsRouteInput struct {
Countries []string `json:"countries" minItems:"1" maxItems:"250"`
SenderID string `json:"senderId" format:"uuid"`
FallbackID string `json:"fallbackId,omitempty"`
}
SmsRouteInput is one route.
type SmsRouteLine ¶
type SmsRouteLine struct {
Countries []string `json:"countries"`
Provider string `json:"provider"`
Adapter string `json:"adapter"`
Sender string `json:"sender"`
// Skipped is why these countries get nothing (pending, no_route…).
Skipped string `json:"skipped,omitempty"`
Recipients int64 `json:"recipients"`
}
SmsRouteLine is one part of the composer's route line: "US and Canada via Twilio +1 888 555 0142", "Ireland skipped (pending) · 20".
type SmsRouteSummary ¶
type SmsRouteSummary struct {
ID string `json:"id"`
Countries []string `json:"countries"`
Provider string `json:"provider"`
Sender string `json:"sender"`
// Fallback is the fallback sender ("" is "None: hold and notify").
Fallback string `json:"fallback"`
FallbackProvider string `json:"fallbackProvider"`
// Registration is the sender's status there; Skipped is true when it
// holds every text (pending, rejected).
Registration string `json:"registration"`
Skipped bool `json:"skipped"`
}
SmsRouteSummary is a route as the providers page sums it up.
type SmsRouteTest ¶
type SmsRouteTest struct {
Number string `json:"number"`
Country string `json:"country"`
CallingCode string `json:"callingCode"`
// Route is how the country is covered: route, other (every other
// country) or none.
Route string `json:"route" enum:"route,other,none"`
RouteCountries []string `json:"routeCountries"`
Provider string `json:"provider"`
Adapter string `json:"adapter"`
Sender string `json:"sender"`
SenderKind string `json:"senderKind"`
CanReply bool `json:"canReply"`
Registration SmsRegistrationView `json:"registration"`
CanSend bool `json:"canSend"`
Price float64 `json:"price"`
Segments int `json:"segments"`
Cost float64 `json:"cost"`
Suppressed string `json:"suppressed,omitempty"`
Zone string `json:"zone"`
ZoneSource string `json:"zoneSource"`
Local string `json:"local"`
Inside bool `json:"inside"`
Opens string `json:"opens"`
Window string `json:"window"`
// HelpNumber is the number people can text for HELP when the sender is
// an ID they can't reply to.
HelpNumber string `json:"helpNumber,omitempty"`
}
SmsRouteTest is the route tester's answer.
type SmsRouteTestInput ¶
type SmsRouteTestInput struct {
Phone string `json:"phone" minLength:"3" maxLength:"40"`
// Message is a campaign ("campaign:<id>") or a reply ("help", "opt_out")
// to count its segments; empty is a one-segment text.
Message string `json:"message,omitempty" maxLength:"60"`
}
SmsRouteTestInput asks which sender would text a number.
type SmsRouteView ¶
type SmsRouteView struct {
ID string `json:"id"`
Countries []string `json:"countries"`
SenderID string `json:"senderId"`
Sender string `json:"sender"`
SenderKind string `json:"senderKind"`
Provider string `json:"provider"`
Adapter string `json:"adapter"`
// Registration is the sender's status in the route's countries.
Registration SmsRegistrationView `json:"registration"`
FallbackID string `json:"fallbackId,omitempty"`
Fallback string `json:"fallback,omitempty"`
FallbackProvider string `json:"fallbackProvider,omitempty"`
// OnLists counts the people on SMS lists in these countries.
OnLists int64 `json:"onLists"`
// Skipped is true when the sender can't text these countries yet.
Skipped bool `json:"skipped"`
}
SmsRouteView is a route in Routing & rules.
type SmsRoutesInput ¶
type SmsRoutesInput struct {
Routes []SmsRouteInput `json:"routes" maxItems:"100"`
// Other is "every other country": dont_send, or the route at OtherRoute.
Other string `json:"other" enum:"dont_send,route"`
OtherRoute int `json:"otherRoute,omitempty" minimum:"0"`
}
SmsRoutesInput replaces the routes.
type SmsRules ¶
type SmsRules struct {
Routes []SmsRouteView `json:"routes"`
Other string `json:"other" enum:"dont_send,route"`
OtherRouteID string `json:"otherRouteId,omitempty"`
OtherPeople int64 `json:"otherPeople"`
Gaps []SmsRouteGap `json:"gaps"`
Senders []SmsSenderOption `json:"senders"`
// Quiet hours.
QuietFrom string `json:"quietFrom"`
QuietTo string `json:"quietTo"`
Assumed int64 `json:"assumed"`
Zones []SmsZoneNow `json:"zones"`
PushWindow bool `json:"pushWindow"`
WhatsAppWindow bool `json:"whatsAppWindow"`
// Keywords and replies.
OptOutKeywords []string `json:"optOutKeywords"`
OptInKeywords []string `json:"optInKeywords"`
HelpKeywords []string `json:"helpKeywords"`
HelpReply SmsReplyView `json:"helpReply"`
OptOutReply SmsReplyView `json:"optOutReply"`
OptInReply SmsReplyView `json:"optInReply"`
KeywordsBy string `json:"keywordsBy" enum:"reputecast,provider"`
// ProviderAnswers names the connected providers that can answer
// keywords themselves.
ProviderAnswers []string `json:"providerAnswers"`
// Budget and guards.
Budget float64 `json:"budget"`
AlertPct int `json:"alertPct"`
Spent float64 `json:"spent"`
Month time.Time `json:"month"`
BudgetSetBy string `json:"budgetSetBy,omitempty"`
BudgetSetAt *time.Time `json:"budgetSetAt,omitempty"`
Thresholds SmsThresholds `json:"thresholds"`
// Test numbers.
TestNumbers []SmsTestNumber `json:"testNumbers"`
TestsSent int64 `json:"testsSent"`
TestsCost float64 `json:"testsCost"`
Members []SmsMemberOption `json:"members"`
RetentionDays int `json:"retentionDays"`
// Message rules.
BrandPrefix string `json:"brandPrefix"`
OptOutText string `json:"optOutText"`
OptOutInSteps bool `json:"optOutInSteps"`
ConfirmationOn bool `json:"confirmationOn"`
Confirmation SmsReplyView `json:"confirmation"`
RequireYes bool `json:"requireYes"`
ShortDomain SmsShortDomain `json:"shortDomain"`
UpdatedAt *time.Time `json:"updatedAt,omitempty"`
UpdatedBy string `json:"updatedBy,omitempty"`
CanManage bool `json:"canManage"`
Helpers []string `json:"helpers"`
Timezone string `json:"timezone"`
}
SmsRules is Routing & rules.
type SmsRulesInput ¶
type SmsRulesInput struct {
QuietFrom string `json:"quietFrom" pattern:"^([01]\\d|2[0-3]):[0-5]\\d$"`
QuietTo string `json:"quietTo" pattern:"^([01]\\d|2[0-3]):[0-5]\\d$"`
PushWindow bool `json:"pushWindow"`
WhatsAppWindow bool `json:"whatsAppWindow"`
OptOutKeywords []string `json:"optOutKeywords" maxItems:"30"`
OptInKeywords []string `json:"optInKeywords" maxItems:"30"`
HelpKeywords []string `json:"helpKeywords" maxItems:"30"`
HelpReply string `json:"helpReply" maxLength:"640"`
OptOutReply string `json:"optOutReply" maxLength:"640"`
OptInReply string `json:"optInReply" maxLength:"640"`
KeywordsBy string `json:"keywordsBy" enum:"reputecast,provider"`
Budget float64 `json:"budget" minimum:"0"`
AlertPct int `json:"alertPct" minimum:"1" maximum:"100"`
Thresholds SmsThresholds `json:"thresholds"`
RetentionDays int `json:"retentionDays" enum:"0,7,30,60,90"`
BrandPrefix string `json:"brandPrefix" maxLength:"20"`
OptOutText string `json:"optOutText" maxLength:"60"`
OptOutInSteps bool `json:"optOutInSteps"`
ConfirmationOn bool `json:"confirmationOn"`
Confirmation string `json:"confirmation" maxLength:"640"`
RequireYes bool `json:"requireYes"`
}
SmsRulesInput saves Routing & rules (routes apart).
type SmsSchedule ¶
type SmsSchedule struct {
Mode string `json:"mode" enum:"now,at,local"`
SendAt *time.Time `json:"sendAt,omitempty"`
LocalDate string `json:"localDate,omitempty"`
LocalTime string `json:"localTime,omitempty"`
// Window is the quiet-hours window ("09:00–20:00"); only times inside
// it are offered for the local schedule.
Window string `json:"window"`
WindowFrom int `json:"windowFrom"`
WindowTo int `json:"windowTo"`
Groups []SmsZoneGroup `json:"groups"`
// Now is the groups if the send started now (the "Now" option's note).
Now []SmsZoneGroup `json:"now"`
// End is when the last text goes, by the senders' throughput.
End *time.Time `json:"end,omitempty"`
}
SmsSchedule is when a campaign goes out.
type SmsSendAction ¶
type SmsSendAction struct {
Action string `json:"action" enum:"pause,resume,cancel"`
// Reason is optional ("Resume with changes" notes what changed).
Reason string `json:"reason,omitempty" maxLength:"500"`
}
SmsSendAction is a person's action on a send: pause, resume or cancel.
type SmsSendInput ¶
type SmsSendInput struct {
Fingerprint string `json:"fingerprint" minLength:"1"`
// Confirm is the typed recipient count, for sends above 1,000
// recipients or $100.
Confirm string `json:"confirm,omitempty"`
// Acknowledged are the warnings' keys the person confirmed.
Acknowledged []string `json:"acknowledged,omitempty"`
}
SmsSendInput sends or schedules a campaign as reviewed.
type SmsSendResult ¶
type SmsSendResult struct {
Status string `json:"status" enum:"scheduled,sending"`
Recipients int64 `json:"recipients"`
ScheduledAt time.Time `json:"scheduledAt"`
}
SmsSendResult is what happened.
type SmsSendSettings ¶
type SmsSendSettings struct {
Mode string `json:"mode,omitempty" enum:"now,at,local"`
SendAt *time.Time `json:"sendAt,omitempty"`
LocalDate string `json:"localDate,omitempty" pattern:"^\\d{4}-\\d{2}-\\d{2}$"`
LocalTime string `json:"localTime,omitempty" pattern:"^([01]\\d|2[0-3]):[0-5]\\d$"`
PendingPolicy string `json:"pendingPolicy,omitempty" enum:"skip,wait"`
Thresholds *SmsThresholds `json:"thresholds,omitempty"`
}
SmsSendSettings changes when and how a campaign goes out.
type SmsSendView ¶
type SmsSendView struct {
Phase string `json:"phase" enum:"scheduled,sending,paused,completed,cancelled"`
ScheduledAt time.Time `json:"scheduledAt"`
StartedBy string `json:"startedBy"`
PausedKind string `json:"pausedKind" enum:"auto,person,outage,budget,"`
PausedAt *time.Time `json:"pausedAt,omitempty"`
}
SmsSendView is a campaign's send, once scheduled.
type SmsSenderIDInput ¶
type SmsSenderIDInput struct {
ProviderID string `json:"providerId" format:"uuid"`
Value string `json:"value" minLength:"1" maxLength:"11"`
Countries []string `json:"countries" minItems:"1" maxItems:"60"`
}
SmsSenderIDInput adds an alphanumeric sender ID.
type SmsSenderOption ¶
type SmsSenderOption struct {
ID string `json:"id"`
Label string `json:"label"`
Kind string `json:"kind"`
Provider string `json:"provider"`
Adapter string `json:"adapter"`
Countries []string `json:"countries"`
// Sendable are the countries its registration lets it text.
Sendable []string `json:"sendable"`
}
SmsSenderOption is a sender a route can use.
type SmsSenderPath ¶
type SmsSenderPath struct {
api.WorkspaceInput
SenderID string `path:"senderId" format:"uuid" doc:"Sender id"`
}
SmsSenderPath names a sender.
type SmsSenderReport ¶
type SmsSenderReport struct {
Provider string `json:"provider"`
Adapter string `json:"adapter"`
Sender string `json:"sender"`
SenderKind string `json:"senderKind"`
Countries []string `json:"countries"`
Sent int64 `json:"sent"`
Delivered int64 `json:"delivered"`
DeliveredPct float64 `json:"deliveredPct"`
Failed int64 `json:"failed"`
Cost float64 `json:"cost"`
Throughput float64 `json:"throughput"`
// ZoneSeconds is the longest any time zone took to go out.
ZoneSeconds float64 `json:"zoneSeconds"`
}
SmsSenderReport is a sender's part of the send.
type SmsSenderRow ¶
type SmsSenderRow struct {
ID string `json:"id"`
Value string `json:"value"`
Label string `json:"label"`
Kind string `json:"kind" enum:"toll_free,10dlc,local,mobile,sender_id"`
ProviderID string `json:"providerId"`
Provider string `json:"provider"`
Adapter string `json:"adapter"`
Countries []string `json:"countries"`
// Registration is the row's status; Brand and Campaign a 10DLC
// number's two parts.
Registration SmsRegistrationView `json:"registration"`
Brand *SmsRegistrationView `json:"brand,omitempty"`
Campaign *SmsRegistrationView `json:"campaign,omitempty"`
Throughput float64 `json:"throughput"`
// Routes are the routes that use it, by their countries; Held is true
// when they hold its texts (registration pending).
Routes [][]string `json:"routes"`
Held bool `json:"held"`
// Manual is true when the status is set by hand here.
Manual bool `json:"manual"`
// CanSend is false when its registration stops it.
CanSend bool `json:"canSend"`
}
SmsSenderRow is a row of the senders table: a sender, or a sender ID's countries that share one registration status.
type SmsSenderRows ¶
type SmsSenderRows struct {
Items []SmsSenderRow `json:"items"`
}
SmsSenderRows is the senders table.
type SmsSenderUpdate ¶
type SmsSenderUpdate struct {
Countries []string `json:"countries" minItems:"1" maxItems:"60"`
}
SmsSenderUpdate changes a sender's countries.
type SmsShortDomain ¶
type SmsShortDomain struct {
Domain string `json:"domain"`
Status string `json:"status" enum:"none,pending,verified,failed"`
Target string `json:"target"`
CheckedAt *time.Time `json:"checkedAt,omitempty"`
VerifiedAt *time.Time `json:"verifiedAt,omitempty"`
Detail string `json:"detail,omitempty"`
// TXTName and TXTValue are the TXT record the domain needs besides its
// CNAME when the CNAME alone doesn't show it's this workspace's: another
// workspace used it first, or it's under this ReputeCast's own address.
// Both are empty otherwise.
TXTName string `json:"txtName"`
TXTValue string `json:"txtValue"`
}
SmsShortDomain is the short-link domain's state.
type SmsShortDomainInput ¶
type SmsShortDomainInput struct {
Domain string `json:"domain" maxLength:"253"`
}
SmsShortDomainInput sets the short-link domain.
type SmsStep ¶
type SmsStep struct{ S *Service }
SmsStep sends "Send SMS" steps (implements automations.ChannelStep).
func (SmsStep) Condition ¶
func (st SmsStep) Condition(ctx context.Context, tx pgx.Tx, in automations.ChannelCheck) (bool, time.Time, error)
Condition implements automations.ChannelStep.
func (SmsStep) CostSince ¶
func (st SmsStep) CostSince(ctx context.Context, workspaceID uuid.UUID, automationIDs []uuid.UUID, since time.Time) (map[uuid.UUID]float64, error)
CostSince implements automations.ChannelCoster: what each flow's texts cost since a time, for the automations list.
func (SmsStep) Permission ¶
func (SmsStep) Permission() authz.Permission
Permission implements automations.ChannelStep: publishing a flow with an SMS step needs sms:send.
func (SmsStep) PublishChecks ¶
func (st SmsStep) PublishChecks(ctx context.Context, workspaceID uuid.UUID, nodes []automations.AutomationNode) ([]automations.AutomationPublishCheck, error)
PublishChecks implements automations.ChannelPublishChecker (brief §6): quiet hours, and the senders' registration in the countries of the contacts with SMS consent on the steps' lists. A country whose sender can't send yet is a warning: the steps skip the texts there, as Send does.
func (SmsStep) Send ¶
func (st SmsStep) Send(ctx context.Context, tx pgx.Tx, in automations.ChannelSend) (automations.ChannelSent, error)
Send implements automations.ChannelStep: consent, the number, the suppression list and "Skip if" first; then quiet hours (wait or skip); then the route; then the text is queued.
func (SmsStep) Validate ¶
func (SmsStep) Validate(n automations.AutomationNode) []automations.ChannelIssue
Validate implements automations.ChannelStep: each issue keeps its message, so the canvas shows it in the member's language.
type SmsStepEstimate ¶
type SmsStepEstimate struct {
Prefix string `json:"prefix"`
OptOut string `json:"optOut"`
Counter SmsCounter `json:"counter"`
Links []SmsLinkView `json:"links"`
// Texts are the people with SMS consent on the list who'd get it now.
Texts int64 `json:"texts"`
Costs []CountryLine `json:"costs"`
Cost float64 `json:"cost"`
Budget SmsBudgetView `json:"budget"`
Window string `json:"window"`
Shorteners []string `json:"shorteners"`
ShortDomain string `json:"shortDomain"`
}
SmsStepEstimate is the step panel's counter and estimated cost.
type SmsStepEstimateInput ¶
type SmsStepEstimateInput struct {
Body string `json:"body" maxLength:"1000"`
ConsentListID string `json:"consentListId,omitempty"`
NoOptOut bool `json:"noOptOut,omitempty"`
}
SmsStepEstimateInput asks what an SMS step would send.
type SmsStepStats ¶
type SmsStepStats struct {
NodeID string `json:"nodeId"`
Sent int64 `json:"sent"`
Delivered int64 `json:"delivered"`
Clicks int64 `json:"clicks"`
OptOuts int64 `json:"optOuts"`
Skipped int64 `json:"skipped"`
Cost float64 `json:"cost"`
Waiting int64 `json:"waiting"`
// SkippedBy counts the skipped texts by reason (no_consent,
// sender_pending, quiet_hours…) and SkippedIn by country.
SkippedBy map[string]int64 `json:"skippedBy"`
SkippedIn map[string]int64 `json:"skippedIn"`
FirstAt *time.Time `json:"firstAt,omitempty"`
LastAt *time.Time `json:"lastAt,omitempty"`
}
SmsStepStats are a step's numbers over 30 days.
type SmsStepStatsList ¶
type SmsStepStatsList struct {
Days int `json:"days"`
Steps []SmsStepStats `json:"steps"`
}
SmsStepStatsList is a flow's SMS steps' stats.
type SmsSuppression ¶
type SmsSuppression struct {
ID string `json:"id"`
Number string `json:"number"`
Reason string `json:"reason" enum:"opted_out,landline,not_in_service,invalid,filtered,provider_list,manual"`
// Code is the provider's own code ("Twilio 30005") or the word ("STOP").
Code string `json:"code"`
Source string `json:"source"`
At time.Time `json:"at"`
// Campaign or Automation is what the number was sent; Context what
// else it was ("Opt-in confirmation").
Campaign string `json:"campaign,omitempty"`
Automation string `json:"automation,omitempty"`
Context string `json:"context,omitempty"`
// Removable is false for numbers that opted out by text: only the
// person can come back, by texting START.
Removable bool `json:"removable"`
}
SmsSuppression is a number on the SMS suppression list, partly masked.
type SmsSuppressionAdd ¶
type SmsSuppressionAdd struct {
Numbers []string `json:"numbers" minItems:"1" maxItems:"100"`
Note string `json:"note,omitempty" maxLength:"500"`
}
SmsSuppressionAdd puts numbers on the list by hand.
type SmsSuppressionFilter ¶
SmsSuppressionFilter filters the list.
type SmsSuppressionList ¶
type SmsSuppressionList struct {
Items []SmsSuppression `json:"items"`
Total int64 `json:"total"`
Matching int64 `json:"matching"`
Counts map[string]int64 `json:"counts"`
Providers []SmsSuppressionProvider `json:"providers"`
Page int `json:"page"`
PageSize int `json:"pageSize"`
CanEdit bool `json:"canEdit"`
Reason string `json:"reason,omitempty"`
// FilteredRecent is how many texts carriers filtered in 30 days: a
// failure, not a suppression, named in the list's summary.
FilteredRecent int64 `json:"filteredRecent"`
}
SmsSuppressionList is Audience › Suppressions filtered to SMS.
type SmsSuppressionProvider ¶
SmsSuppressionProvider is a provider to filter by.
type SmsSuppressionRemove ¶
type SmsSuppressionRemove struct {
Reason string `json:"reason" minLength:"3" maxLength:"500"`
}
SmsSuppressionRemove takes a number off the list.
type SmsSuppressionsAdded ¶
type SmsSuppressionsAdded struct {
Added int `json:"added"`
}
SmsSuppressionsAdded says how many numbers went on the list.
type SmsTerms ¶
type SmsTerms struct {
Version int `json:"version"`
PublishedAt *time.Time `json:"publishedAt,omitempty"`
PublishedBy string `json:"publishedBy,omitempty"`
Content SmsTermsContent `json:"content"`
// Generated is what the rules would write now: the editor's "Reset".
Generated SmsTermsContent `json:"generated"`
URL string `json:"url"`
CanEdit bool `json:"canEdit"`
}
SmsTerms is the terms page in Forms & pages.
type SmsTermsContent ¶
type SmsTermsContent struct {
Intro string `json:"intro" maxLength:"1000"`
Program string `json:"program" maxLength:"500"`
Frequency string `json:"frequency" maxLength:"300"`
Cost string `json:"cost" maxLength:"300"`
Help string `json:"help" maxLength:"500"`
OptOut string `json:"optOut" maxLength:"500"`
Senders string `json:"senders" maxLength:"500"`
Privacy string `json:"privacy" maxLength:"500"`
Carriers string `json:"carriers" maxLength:"300"`
// PrivacyURL links the privacy policy.
PrivacyURL string `json:"privacyUrl,omitempty" maxLength:"500"`
// HelpNumber and HelpEmail are shown as links in the Help section.
HelpNumber string `json:"helpNumber,omitempty" maxLength:"40"`
HelpEmail string `json:"helpEmail,omitempty" maxLength:"200"`
// Address is the sender's postal address, at the foot of the page.
Address string `json:"address,omitempty" maxLength:"300"`
}
SmsTermsContent is the page's text, section by section.
type SmsTestInput ¶
type SmsTestInput struct {
// Numbers are test numbers' ids; empty sends to every test number.
Numbers []string `json:"numbers,omitempty" maxItems:"20"`
}
SmsTestInput sends test texts.
type SmsTestNumber ¶
type SmsTestNumber struct {
ID string `json:"id"`
Name string `json:"name"`
Role string `json:"role"`
Color string `json:"color"`
Phone string `json:"phone"`
Display string `json:"display"`
Country string `json:"country"`
UserID string `json:"userId,omitempty"`
LastTest *SmsTestResult `json:"lastTest,omitempty"`
}
SmsTestNumber is a member's phone for test texts, with its last test.
type SmsTestNumberInput ¶
type SmsTestNumberInput struct {
UserID string `json:"userId,omitempty"`
Phone string `json:"phone" minLength:"3" maxLength:"40"`
}
SmsTestNumberInput adds a member's phone for test texts.
type SmsTestNumberList ¶
type SmsTestNumberList struct {
Items []SmsTestNumber `json:"items"`
}
SmsTestNumberList is the test numbers with their last test.
type SmsTestResult ¶
type SmsTestResult struct {
MessageID string `json:"messageId"`
Status string `json:"status" enum:"queued,held,skipped,sending,sent,delivered,undelivered,failed,cancelled"`
At time.Time `json:"at"`
Provider string `json:"provider"`
Sender string `json:"sender"`
SenderID bool `json:"senderId"`
Seconds *float64 `json:"seconds,omitempty"`
Delivered *time.Time `json:"delivered,omitempty"`
}
SmsTestResult is a test text and how it went.
type SmsThresholds ¶
type SmsThresholds struct {
Failed float64 `json:"failed" minimum:"0.1" maximum:"100"`
Filtered float64 `json:"filtered" minimum:"0.1" maximum:"100"`
OptOuts float64 `json:"optOuts" minimum:"0.1" maximum:"100"`
}
SmsThresholds are a campaign's auto-pause thresholds, in percent.
type SmsTimePoint ¶
SmsTimePoint is the cumulative delivered count at a moment.
type SmsTimelineSample ¶
type SmsTimelineSample struct {
ContactID string `json:"contactId"`
Name string `json:"name"`
Events []SmsTimelineSampleEv `json:"events"`
}
SmsTimelineSample is one recipient's events, as their timeline shows them.
type SmsTimelineSampleEv ¶
type SmsTimelineSampleEv struct {
Kind string `json:"kind"`
At time.Time `json:"at"`
Provider string `json:"provider,omitempty"`
Sender string `json:"sender,omitempty"`
Seconds float64 `json:"seconds,omitempty"`
Link string `json:"link,omitempty"`
Target string `json:"target,omitempty"`
Body string `json:"body,omitempty"`
}
SmsTimelineSampleEv is one event of the sample.
type SmsWebhookSetup ¶
type SmsWebhookSetup struct {
Mode string `json:"mode" enum:"registered,manual"`
URL string `json:"url"`
// Secret is shown once, in manual mode, to paste in the provider's
// console; ReputeCast keeps it sealed.
Secret string `json:"secret,omitempty"`
// Error is why registering through the API failed.
Error string `json:"error,omitempty"`
}
SmsWebhookSetup is how receipts and inbound texts reach ReputeCast.
type SmsZoneGroup ¶
type SmsZoneGroup struct {
Countries []string `json:"countries"`
Recipients int64 `json:"recipients"`
From time.Time `json:"from"`
To time.Time `json:"to"`
// LocalFrom and LocalTo: the local clock times for "Now" ("13:40").
LocalFrom string `json:"localFrom"`
LocalTo string `json:"localTo"`
// Held is true when quiet hours hold them; Until is when they go.
Held bool `json:"held"`
Until time.Time `json:"until"`
}
SmsZoneGroup is a group of recipients who get the text at the same moment or in one range: "08:00 UTC · Germany, Netherlands · 77".
type SmsZoneNow ¶
type SmsZoneNow struct {
Zone string `json:"zone"`
Local string `json:"local"`
Inside bool `json:"inside"`
// Opens is when texts go next ("09:00").
Opens string `json:"opens"`
}
SmsZoneNow is the local time in a zone, for the quiet-hours preview.
type SmsZoneStep ¶
type SmsZoneStep struct {
At time.Time `json:"at"`
Countries []string `json:"countries"`
// Region names a part of a country with several zones: atlantic, east,
// central, mountain, pacific.
Region string `json:"region,omitempty"`
Zone string `json:"zone"`
// Local and Abbr: the local time and the zone's abbreviation ("10:00",
// "CEST").
Local string `json:"local"`
Abbr string `json:"abbr"`
Total int64 `json:"total"`
Sent int64 `json:"sent"`
Delivered int64 `json:"delivered"`
// Status is sent, sending, waiting, paused or held.
Status string `json:"status" enum:"sent,sending,waiting,paused,held"`
}
SmsZoneStep is a time zone's texts going out: "08:00 UTC · Germany, Netherlands · +76".
type SweepArgs ¶
type SweepArgs struct{}
SweepArgs re-queues webhooks whose normalization never finished, purges text content past the workspace's retention and events past 90 days, and expires short links after 12 months.
func (SweepArgs) InsertOpts ¶
func (SweepArgs) InsertOpts() river.InsertOpts
InsertOpts implements river.JobArgsWithInsertOpts.
type SweepWorker ¶
type SweepWorker struct {
river.WorkerDefaults[SweepArgs]
S *Service
}
SweepWorker runs SweepArgs.
Source Files
¶
- agents.go
- api.go
- audience.go
- automation.go
- campaigns.go
- campaignslist.go
- compose.go
- consent.go
- dispatch.go
- erasure.go
- events.go
- export.go
- health.go
- importer.go
- inbound.go
- ingest.go
- jobs.go
- lang.go
- links.go
- move.go
- prefs.go
- providers.go
- receipts.go
- report.go
- review.go
- routing.go
- rules.go
- send.go
- settings.go
- signup.go
- suppressions.go
- terms.go
- tests.go
- texting.go
- timeline.go