Documentation
¶
Overview ¶
Package whatsapp is ReputeCast's WhatsApp channel (design expansion phase 8, M32, optional): Meta's WhatsApp Cloud API, the only WhatsApp provider in this release, reached over plain HTTP (internal/whatsapp/meta).
- The account: a WhatsApp Business Account, its phone number and a system user's access token, with the app secret that signs Meta's webhooks. Credentials are sealed (internal/secrets) and never returned. The display name, quality rating and messaging limit are shown as Meta reports them.
- Templates, synced from Meta every hour and on demand. They're created and edited in Meta's WhatsApp Manager; ReputeCast reads them.
- WhatsApp consent per list, like SMS consent (channel_consents with channel 'whatsapp'); the SMS opt-out keywords work on WhatsApp too.
- The 24-hour customer service window: free-form messages only go to people who wrote in the last 24 hours.
- WhatsApp campaigns with an approved template, its variables mapped to contact fields with fallbacks, the pre-send checks (consent, the template, the quality rating, the messaging limit and the cost from Meta's rate card), and the report.
- The Send WhatsApp automation step.
- Meta's webhooks: verified with the app secret, stored raw, answered 200 at once and normalized by a River job.
WhatsApp builds on X21's channel model: campaigns carry channel 'whatsapp', each message is a row of the message log (90 days, never the audit log), suppressions are channel_suppressions. Everything a person changes is audited.
Index ¶
- Constants
- Variables
- func LanguageLabel(code string) string
- func LanguageLabelIn(l i18n.Lang, code string) string
- func Register(h huma.API, s *Service)
- func RegisterJobs(reg *jobs.Registry, s *Service)
- type Approvals
- type DispatchArgs
- type DispatchWorker
- type NormalizeArgs
- type NormalizeWorker
- type SegmentResolver
- type Service
- func (s *Service) Campaign(ctx context.Context, ws *store.Workspace, p *authz.Principal, ...) (WhatsAppCampaign, error)
- func (s *Service) CampaignReport(ctx context.Context, ws *store.Workspace, id uuid.UUID) (WhatsAppReport, error)
- func (s *Service) Cancel(ctx context.Context, ws *store.Workspace, id uuid.UUID) error
- func (s *Service) Check(ctx context.Context, ws *store.Workspace, p *authz.Principal) error
- func (s *Service) Connect(ctx context.Context, ws *store.Workspace, p *authz.Principal, ...) error
- func (s *Service) Connected(ctx context.Context, workspaceID uuid.UUID) (bool, error)
- func (s *Service) ContactActivity(ctx context.Context, ws *store.Workspace, contactID uuid.UUID, ...) ([]audience.ContactActivityItem, int64, error)
- func (s *Service) ContactCard(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (WhatsAppContactCard, error)
- func (s *Service) CreateCampaign(ctx context.Context, ws *store.Workspace, p *authz.Principal, ...) (WhatsAppCampaign, error)
- func (s *Service) DescribeForApproval(ctx context.Context, ws *store.Workspace, campaignID uuid.UUID) (approvals.ChannelCampaign, error)
- func (s *Service) Disconnect(ctx context.Context, ws *store.Workspace, p *authz.Principal) error
- func (s *Service) Dispatch(ctx context.Context, budget time.Duration) (again time.Duration, done bool, err error)
- func (s *Service) DuplicateCampaign(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (WhatsAppCampaign, error)
- func (s *Service) Estimate(ctx context.Context, ws *store.Workspace, listID, templateID string) (WhatsAppEstimate, error)
- func (s *Service) Events(ctx context.Context, ws *store.Workspace, before *time.Time, limit int) (WhatsAppEventList, error)
- func (s *Service) FillChannelRows(ctx context.Context, ws *store.Workspace, items []campaigns.CampaignListItem)
- func (s *Service) HookRoutes(r chi.Router)
- func (s *Service) Ingest(ctx context.Context, slug string, h http.Header, body []byte) int
- func (s *Service) Normalize(ctx context.Context, rawID uuid.UUID) error
- func (s *Service) Overview(ctx context.Context, ws *store.Workspace, p *authz.Principal) (WhatsAppOverview, error)
- func (s *Service) Rates(ctx context.Context, ws *store.Workspace, p *authz.Principal) (WhatsAppRates, error)
- func (s *Service) ReplaceCredentials(ctx context.Context, ws *store.Workspace, p *authz.Principal, ...) error
- func (s *Service) Reply(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) (WhatsAppThreadItem, error)
- func (s *Service) ReportCSV(ctx context.Context, ws *store.Workspace, id uuid.UUID) ([]byte, string, error)
- func (s *Service) Review(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (WhatsAppReview, error)
- func (s *Service) SaveRates(ctx context.Context, ws *store.Workspace, p *authz.Principal, ...) (WhatsAppRates, error)
- func (s *Service) SaveSettings(ctx context.Context, ws *store.Workspace, p *authz.Principal, ...) error
- func (s *Service) Send(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) (WhatsAppSendResult, error)
- func (s *Service) SendAccountTest(ctx context.Context, ws *store.Workspace, p *authz.Principal, ...) (WhatsAppTestResult, error)
- func (s *Service) SendCampaignTest(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) (WhatsAppTestResult, error)
- func (s *Service) SetConsentByTeam(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) (WhatsAppContactCard, error)
- func (s *Service) StartDue(ctx context.Context) error
- func (s *Service) StepEstimate(ctx context.Context, ws *store.Workspace, in WhatsAppStepEstimateInput) (WhatsAppStepEstimate, error)
- func (s *Service) StepStats(ctx context.Context, ws *store.Workspace, automationID uuid.UUID) (WhatsAppStepStatsList, error)
- func (s *Service) Sync(ctx context.Context, ws *store.Workspace, p *authz.Principal, system bool) (WhatsAppSyncResult, error)
- func (s *Service) SyncAll(ctx context.Context) error
- func (s *Service) Templates(ctx context.Context, ws *store.Workspace) ([]WhatsAppTemplate, error)
- func (s *Service) TestStatus(ctx context.Context, ws *store.Workspace, id uuid.UUID) (WhatsAppTestResult, error)
- func (s *Service) Unschedule(ctx context.Context, ws *store.Workspace, id uuid.UUID) error
- func (s *Service) UpdateCampaign(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) (WhatsAppCampaign, error)
- func (s *Service) Verify(ctx context.Context, slug, mode, token, challenge string) (string, bool)
- type StartArgs
- type StartWorker
- type Step
- func (Step) Condition(context.Context, pgx.Tx, automations.ChannelCheck) (bool, time.Time, error)
- func (Step) Permission() authz.Permission
- func (st Step) Send(ctx context.Context, tx pgx.Tx, in automations.ChannelSend) (automations.ChannelSent, error)
- func (Step) Validate(n automations.AutomationNode) []automations.ChannelIssue
- type SweepArgs
- type SweepWorker
- type SyncArgs
- type SyncWorker
- type WhatsAppAccess
- type WhatsAppAccount
- type WhatsAppAudience
- type WhatsAppBusiness
- type WhatsAppCSV
- type WhatsAppCampaign
- type WhatsAppCampaignCreate
- type WhatsAppCampaignPath
- type WhatsAppCampaignTestInput
- type WhatsAppCampaignUpdate
- type WhatsAppCheck
- type WhatsAppConnectInput
- type WhatsAppConsentEvidence
- type WhatsAppConsentInput
- type WhatsAppContactCard
- type WhatsAppContactList
- type WhatsAppContactPath
- type WhatsAppCost
- type WhatsAppCostCountry
- type WhatsAppCredentialsInput
- type WhatsAppEstimate
- type WhatsAppEvent
- type WhatsAppEventList
- type WhatsAppFailure
- type WhatsAppFallback
- type WhatsAppField
- type WhatsAppLimitSplit
- type WhatsAppListConsent
- type WhatsAppOverview
- type WhatsAppPreview
- type WhatsAppRate
- type WhatsAppRates
- type WhatsAppRatesInput
- type WhatsAppReplyInput
- type WhatsAppReport
- type WhatsAppReportCountry
- type WhatsAppReview
- type WhatsAppSchedule
- type WhatsAppSendInput
- type WhatsAppSendResult
- type WhatsAppSendState
- type WhatsAppSettingsInput
- type WhatsAppStepEstimate
- type WhatsAppStepEstimateInput
- type WhatsAppStepStats
- type WhatsAppStepStatsList
- type WhatsAppSuppression
- type WhatsAppSyncResult
- type WhatsAppTemplate
- type WhatsAppTemplateButton
- type WhatsAppTemplateCounts
- type WhatsAppTemplateVar
- type WhatsAppTestInput
- type WhatsAppTestResult
- type WhatsAppThreadItem
- type WhatsAppVariable
- type WhatsAppWindow
- type WhatsAppWindowExample
Constants ¶
const ( Pass = "pass" Warn = "warn" Block = "block" VerdictReady = "ready" VerdictWarnings = "warnings" VerdictBlocked = "blocked" )
Check statuses and verdicts.
const MaxHookBody = 1 << 20
MaxHookBody is the largest webhook accepted.
Variables ¶
var DefaultRates = []WhatsAppRate{
{"US", "marketing", 0.0250}, {"US", "utility", 0.0040}, {"US", "authentication", 0.0040},
{"CA", "marketing", 0.0250}, {"CA", "utility", 0.0040}, {"CA", "authentication", 0.0040},
{"GB", "marketing", 0.0529}, {"GB", "utility", 0.0220}, {"GB", "authentication", 0.0358},
{"DE", "marketing", 0.1365}, {"DE", "utility", 0.0550}, {"DE", "authentication", 0.0768},
{"NL", "marketing", 0.1597}, {"NL", "utility", 0.0500}, {"NL", "authentication", 0.0721},
{"IE", "marketing", 0.0732}, {"IE", "utility", 0.0300}, {"IE", "authentication", 0.0400},
{"FR", "marketing", 0.1432}, {"FR", "utility", 0.0300}, {"FR", "authentication", 0.0690},
{"*", "marketing", 0.0740}, {"*", "utility", 0.0080}, {"*", "authentication", 0.0400},
}
DefaultRates is Meta's rate card of 1 Oct 2026 for the markets the app lists first, and every other country.
var RatesAsOf = time.Date(2026, 10, 1, 0, 0, 0, 0, time.UTC)
RatesAsOf is the date of the rate card this release carries.
Functions ¶
func LanguageLabel ¶
LanguageLabel names a template's language in English: "English (US)".
func LanguageLabelIn ¶
LanguageLabelIn names a template's language in a reader's language; a code ReputeCast has no name for stays the code.
func RegisterJobs ¶
RegisterJobs adds the WhatsApp workers and their schedules.
Types ¶
type Approvals ¶
type Approvals interface {
ChannelGate(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (*store.ApprovalRequest, error)
ChannelReview(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (approvals.ReviewApproval, error)
}
Approvals is the approvals seam for WhatsApp campaigns.
type DispatchArgs ¶
type DispatchArgs struct{}
DispatchArgs sends the messages 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) 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 NormalizeArgs ¶
NormalizeArgs normalizes one stored 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) Work ¶
func (w *NormalizeWorker) Work(ctx context.Context, job *river.Job[NormalizeArgs]) error
Work implements river.Worker.
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
// 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 Meta's Graph API is called through
// (the in-process Graph API in tests).
HTTP *http.Client
// Demo is the in-process Graph API the demo's account answers from:
// it never reaches Meta.
Demo func() *metatest.Fake
// Segments resolves a segment's contacts for an audience.
Segments SegmentResolver
// Approvals evaluates the workspace's approval rules for WhatsApp
// campaigns and holds their requests (internal/approvals).
Approvals Approvals
// Changed re-checks a campaign's open approval after an edit.
Changed func(ctx context.Context, ws *store.Workspace, campaignID uuid.UUID)
}
Service is the WhatsApp domain.
func (*Service) Campaign ¶
func (s *Service) Campaign(ctx context.Context, ws *store.Workspace, p *authz.Principal, id, preview uuid.UUID) (WhatsAppCampaign, error)
Campaign is the composer's view; preview names the contact the preview shows (uuid.Nil picks one of the audience).
func (*Service) CampaignReport ¶
func (s *Service) CampaignReport(ctx context.Context, ws *store.Workspace, id uuid.UUID) (WhatsAppReport, error)
CampaignReport is the report of a WhatsApp campaign.
func (*Service) Check ¶
Check reads the account from Meta now (the card's numbers, "Check again") and syncs the templates. A rejected token holds the sends.
func (*Service) Connect ¶
func (s *Service) Connect(ctx context.Context, ws *store.Workspace, p *authz.Principal, in WhatsAppConnectInput) error
Connect seals the credentials, checks them with Meta and shows the webhook to paste in Meta's app settings. Nothing is sent until Meta verifies the webhook.
func (*Service) Connected ¶
Connected reports whether the workspace can send WhatsApp messages: an account Meta verified. The channel switch shows WhatsApp once it can.
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 WhatsApp on their timeline (implements audience.ActivitySource): each message with its status (types whatsapp_sent, whatsapp_delivered, whatsapp_failed…, read in Detail), what they wrote (whatsapp_reply, whatsapp_button, whatsapp_opt_out, whatsapp_opt_in, whatsapp_help) and every change of WhatsApp consent with its evidence (whatsapp_consent_<action>).
func (*Service) ContactCard ¶
func (s *Service) ContactCard(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (WhatsAppContactCard, error)
ContactCard is a contact's WhatsApp card.
func (*Service) CreateCampaign ¶
func (s *Service) CreateCampaign(ctx context.Context, ws *store.Workspace, p *authz.Principal, in WhatsAppCampaignCreate) (WhatsAppCampaign, error)
CreateCampaign makes a WhatsApp campaign, audited like any campaign.
func (*Service) DescribeForApproval ¶
func (s *Service) DescribeForApproval(ctx context.Context, ws *store.Workspace, campaignID uuid.UUID) (approvals.ChannelCampaign, error)
DescribeForApproval describes a WhatsApp campaign to the approvals domain (approvals.ChannelCampaigns).
func (*Service) Disconnect ¶
Disconnect removes the account: messages waiting to go are cancelled.
func (*Service) Dispatch ¶
func (s *Service) Dispatch(ctx context.Context, budget time.Duration) (again time.Duration, done bool, err error)
Dispatch sends due messages for up to budget. again is when to look next; done is true when nothing is queued at all.
func (*Service) DuplicateCampaign ¶
func (s *Service) DuplicateCampaign(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (WhatsAppCampaign, error)
DuplicateCampaign copies a campaign as a draft (logged).
func (*Service) Estimate ¶
func (s *Service) Estimate(ctx context.Context, ws *store.Workspace, listID, templateID string) (WhatsAppEstimate, error)
Estimate counts a list's people with WhatsApp consent and prices one template to them.
func (*Service) Events ¶
func (s *Service) Events(ctx context.Context, ws *store.Workspace, before *time.Time, limit int) (WhatsAppEventList, error)
Events lists Meta's webhooks, newest first.
func (*Service) FillChannelRows ¶
func (s *Service) FillChannelRows(ctx context.Context, ws *store.Workspace, items []campaigns.CampaignListItem)
FillChannelRows fills in the campaigns list's WhatsApp rows (implements campaigns.ChannelRows): the account's number as the route, delivered and read once messages went, the cost, and the review's verdict before.
func (*Service) HookRoutes ¶
HookRoutes mounts Meta's webhook address.
func (*Service) Ingest ¶
Ingest verifies one webhook, stores it raw and queues its normalization: 200 at once, 401 when the signature fails (the payload is kept, cut short, for diagnosis), 404 for an unknown address, 429 to retry.
func (*Service) Normalize ¶
Normalize turns a stored webhook into events: statuses on their messages, people's messages (keywords, quick replies, replies), template statuses and the number's quality.
func (*Service) Overview ¶
func (s *Service) Overview(ctx context.Context, ws *store.Workspace, p *authz.Principal) (WhatsAppOverview, error)
Overview is Sending providers › WhatsApp.
func (*Service) Rates ¶
func (s *Service) Rates(ctx context.Context, ws *store.Workspace, p *authz.Principal) (WhatsAppRates, error)
Rates is the workspace's rate card.
func (*Service) ReplaceCredentials ¶
func (s *Service) ReplaceCredentials(ctx context.Context, ws *store.Workspace, p *authz.Principal, in WhatsAppCredentialsInput) error
ReplaceCredentials seals new credentials after Meta accepts them. A rejected token's held messages go again (Reconnect).
func (*Service) Reply ¶
func (s *Service) Reply(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in WhatsAppReplyInput) (WhatsAppThreadItem, error)
Reply sends free text to a contact who wrote in the last 24 hours. Like every message it stays in the message log, not the audit log.
func (*Service) ReportCSV ¶
func (s *Service) ReportCSV(ctx context.Context, ws *store.Workspace, id uuid.UUID) ([]byte, string, error)
ReportCSV exports the report by country (logged).
func (*Service) Review ¶
func (s *Service) Review(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (WhatsAppReview, error)
Review is Review & send.
func (*Service) SaveRates ¶
func (s *Service) SaveRates(ctx context.Context, ws *store.Workspace, p *authz.Principal, in WhatsAppRatesInput) (WhatsAppRates, error)
SaveRates replaces the rate card (logged).
func (*Service) SaveSettings ¶
func (s *Service) SaveSettings(ctx context.Context, ws *store.Workspace, p *authz.Principal, in WhatsAppSettingsInput) error
SaveSettings changes whether WhatsApp keeps to the quiet hours (logged). With SMS rules it's their "WhatsApp keeps to the same window".
func (*Service) Send ¶
func (s *Service) Send(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in WhatsAppSendInput) (WhatsAppSendResult, error)
Send sends or schedules the campaign after the checks and the approval rules (logged).
func (*Service) SendAccountTest ¶
func (s *Service) SendAccountTest(ctx context.Context, ws *store.Workspace, p *authz.Principal, in WhatsAppTestInput) (WhatsAppTestResult, error)
SendAccountTest sends an approved template to a member's WhatsApp (logged); the test waits for Meta's delivery report.
func (*Service) SendCampaignTest ¶
func (s *Service) SendCampaignTest(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in WhatsAppCampaignTestInput) (WhatsAppTestResult, error)
SendCampaignTest sends the campaign's template to a member's WhatsApp (logged), its variables filled with the fixed texts and fallbacks.
func (*Service) SetConsentByTeam ¶
func (s *Service) SetConsentByTeam(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in WhatsAppConsentInput) (WhatsAppContactCard, error)
SetConsentByTeam changes WhatsApp consent from the profile or the API (subscribers:edit), audited. Consent needs its evidence; an opt-out by keyword can't be overridden: only the person can come back.
func (*Service) StepEstimate ¶
func (s *Service) StepEstimate(ctx context.Context, ws *store.Workspace, in WhatsAppStepEstimateInput) (WhatsAppStepEstimate, error)
StepEstimate answers the Send WhatsApp step's panel. A list or template that isn't picked yet leaves its parts empty.
func (*Service) StepStats ¶
func (s *Service) StepStats(ctx context.Context, ws *store.Workspace, automationID uuid.UUID) (WhatsAppStepStatsList, error)
StepStats are a flow's WhatsApp steps over 30 days. Skips come from the engine's run log (no consent, no phone, the window closed…).
func (*Service) Sync ¶
func (s *Service) Sync(ctx context.Context, ws *store.Workspace, p *authz.Principal, system bool) (WhatsAppSyncResult, error)
Sync reads the account's templates from Meta (Sync now, the hourly job). A sync that changed something is logged: by the person who asked, or by the system. A newly rejected template tells the providers' managers.
func (*Service) TestStatus ¶
func (s *Service) TestStatus(ctx context.Context, ws *store.Workspace, id uuid.UUID) (WhatsAppTestResult, error)
TestStatus is a test message's status now.
func (*Service) Unschedule ¶
Unschedule takes a scheduled campaign back to a draft (logged).
func (*Service) UpdateCampaign ¶
func (s *Service) UpdateCampaign(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in WhatsAppCampaignUpdate) (WhatsAppCampaign, error)
UpdateCampaign autosaves the composer: the template, its variables, the audience and the schedule.
type StartArgs ¶
type StartArgs struct{}
StartArgs starts the scheduled sends whose time has come.
func (StartArgs) InsertOpts ¶
func (StartArgs) InsertOpts() river.InsertOpts
InsertOpts implements river.JobArgsWithInsertOpts.
type StartWorker ¶
type StartWorker struct {
river.WorkerDefaults[StartArgs]
S *Service
}
StartWorker runs StartArgs.
type Step ¶
type Step struct{ S *Service }
Step sends the "Send WhatsApp" steps (automations.ChannelStep).
func (Step) Permission ¶
func (Step) Permission() authz.Permission
Permission is what publishing a flow with a WhatsApp step needs.
func (Step) Send ¶
func (st Step) Send(ctx context.Context, tx pgx.Tx, in automations.ChannelSend) (automations.ChannelSent, error)
Send queues the step's message for the run's contact.
func (Step) Validate ¶
func (Step) Validate(n automations.AutomationNode) []automations.ChannelIssue
Validate checks the step beyond the engine's own checks.
type SweepArgs ¶
type SweepArgs struct{}
SweepArgs purges what's past its 90 days.
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.
type SyncArgs ¶
type SyncArgs struct{}
SyncArgs checks every account and syncs its templates.
func (SyncArgs) InsertOpts ¶
func (SyncArgs) InsertOpts() river.InsertOpts
InsertOpts implements river.JobArgsWithInsertOpts.
type SyncWorker ¶
type SyncWorker struct {
river.WorkerDefaults[SyncArgs]
S *Service
}
SyncWorker runs SyncArgs.
type WhatsAppAccess ¶
type WhatsAppAccess struct {
CanEdit bool `json:"canEdit"`
CanSend bool `json:"canSend"`
Missing []string `json:"missing"`
Helpers []string `json:"helpers"`
}
WhatsAppAccess is what the viewer may do with a campaign.
type WhatsAppAccount ¶
type WhatsAppAccount struct {
ID string `json:"id"`
Status string `json:"status" enum:"waiting,connected,token_rejected"`
StatusDetail string `json:"statusDetail,omitempty"`
StatusSince *time.Time `json:"statusSince,omitempty"`
BusinessName string `json:"businessName"`
BusinessHint string `json:"businessHint"`
Number string `json:"number"`
DisplayName string `json:"displayName"`
NameStatus string `json:"nameStatus"`
PhoneStatus string `json:"phoneStatus"`
Quality string `json:"quality" enum:"high,medium,low,unknown"`
PreviousQuality string `json:"previousQuality,omitempty"`
QualityChangedAt *time.Time `json:"qualityChangedAt,omitempty"`
MessagingLimit int `json:"messagingLimit"`
PreviousLimit int `json:"previousLimit,omitempty"`
LimitChangedAt *time.Time `json:"limitChangedAt,omitempty"`
ConnectedAt time.Time `json:"connectedAt"`
ConnectedBy string `json:"connectedBy"`
CheckedAt *time.Time `json:"checkedAt,omitempty"`
WebhookURL string `json:"webhookUrl"`
// VerifyToken is shown to who can manage providers, for Meta's app
// settings.
VerifyToken string `json:"verifyToken,omitempty"`
VerifiedAt *time.Time `json:"verifiedAt,omitempty"`
LastEventAt *time.Time `json:"lastEventAt,omitempty"`
TemplatesSyncedAt *time.Time `json:"templatesSyncedAt,omitempty"`
Demo bool `json:"demo"`
// Held are the sends waiting for a new token: names and how many.
Held []string `json:"held"`
HeldCount int64 `json:"heldCount"`
}
WhatsAppAccount is the account card. Credentials are never returned.
type WhatsAppAudience ¶
type WhatsAppAudience struct {
Lists []WhatsAppListConsent `json:"lists"`
// Consent is everyone with WhatsApp consent on the lists, once each.
Consent int64 `json:"consent"`
// Without are the lists' people without it: they get nothing.
Without int64 `json:"without"`
// Suppressed opted out on WhatsApp; Final is who it goes to.
Suppressed int64 `json:"suppressed"`
Final int64 `json:"final"`
// Countries are the recipients by country, for the cost.
Countries map[string]int64 `json:"countries"`
}
WhatsAppAudience is a campaign's people.
type WhatsAppBusiness ¶
type WhatsAppBusiness struct {
DisplayName string `json:"displayName"`
Number string `json:"number"`
}
WhatsAppBusiness is who the person talks to.
type WhatsAppCSV ¶
type WhatsAppCSV struct {
ContentType string `header:"Content-Type"`
ContentDisposition string `header:"Content-Disposition"`
Body []byte
}
WhatsAppCSV is a CSV download.
type WhatsAppCampaign ¶
type WhatsAppCampaign 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"`
UpdatedAt time.Time `json:"updatedAt"`
UpdatedBy string `json:"updatedBy"`
CreatedBy string `json:"createdBy"`
TemplateID string `json:"templateId,omitempty"`
Template *WhatsAppTemplate `json:"template,omitempty"`
// Templates are every template: the picker offers the approved ones.
Templates []WhatsAppTemplate `json:"templates"`
Variables []WhatsAppVariable `json:"variables"`
ListOptions []WhatsAppListConsent `json:"listOptions"`
Segments []string `json:"segments"`
Audience WhatsAppAudience `json:"audience"`
Schedule WhatsAppSchedule `json:"schedule"`
OverLimit string `json:"overLimit" enum:"next_day,skip"`
Quiet bool `json:"quiet"`
Window string `json:"window"`
Preview *WhatsAppPreview `json:"preview,omitempty"`
Cost WhatsAppCost `json:"cost"`
Business *WhatsAppBusiness `json:"business,omitempty"`
Fields []WhatsAppField `json:"fields"`
Access WhatsAppAccess `json:"access"`
Connected bool `json:"connected"`
// AccountStatus is waiting, connected or token_rejected.
AccountStatus string `json:"accountStatus"`
Test *WhatsAppTestResult `json:"test,omitempty"`
}
WhatsAppCampaign is the composer.
type WhatsAppCampaignCreate ¶
type WhatsAppCampaignCreate struct {
Name string `json:"name" minLength:"1" maxLength:"200"`
TemplateID string `json:"templateId,omitempty" maxLength:"40"`
Lists []string `json:"lists,omitempty" maxItems:"50"`
}
WhatsAppCampaignCreate makes a campaign.
type WhatsAppCampaignPath ¶
type WhatsAppCampaignPath struct {
api.WorkspaceInput
CampaignID string `path:"campaignId" format:"uuid" doc:"Campaign id"`
}
WhatsAppCampaignPath names a WhatsApp campaign.
type WhatsAppCampaignTestInput ¶
type WhatsAppCampaignTestInput struct {
Phone string `json:"phone" minLength:"1" maxLength:"40"`
}
WhatsAppCampaignTestInput sends a campaign to a member's WhatsApp.
type WhatsAppCampaignUpdate ¶
type WhatsAppCampaignUpdate struct {
Name string `json:"name" minLength:"1" maxLength:"200"`
TemplateID string `json:"templateId" maxLength:"40"`
Variables []WhatsAppVariable `json:"variables" maxItems:"20"`
Lists []string `json:"lists" maxItems:"50"`
Segments []string `json:"segments,omitempty" maxItems:"50"`
Mode string `json:"mode" enum:"now,at,local"`
SendAt *time.Time `json:"sendAt,omitempty"`
LocalDate string `json:"localDate,omitempty" pattern:"^(\\d{4}-\\d{2}-\\d{2})?$"`
LocalMinute *int `json:"localMinute,omitempty" minimum:"0" maximum:"1439"`
OverLimit string `json:"overLimit,omitempty" enum:"next_day,skip,"`
// Version is the version the composer edited; a save from an older one
// is refused.
Version int `json:"version" minimum:"0"`
}
WhatsAppCampaignUpdate is an autosave from the composer.
type WhatsAppCheck ¶
type WhatsAppCheck struct {
Key string `json:"key" enum:"account,consent,template,quality,limit,cost,approval"`
Status string `json:"status" enum:"pass,warn,block"`
// Account.
AccountStatus string `json:"accountStatus,omitempty"`
// Consent.
Count int64 `json:"count"`
Lists []string `json:"lists"`
Without int64 `json:"without"`
// Template.
Template string `json:"template,omitempty"`
Category string `json:"category,omitempty"`
TStatus string `json:"templateStatus,omitempty"`
// Quality.
Quality string `json:"quality,omitempty"`
PreviousQuality string `json:"previousQuality,omitempty"`
QualityAt *time.Time `json:"qualityAt,omitempty"`
CheckedAt *time.Time `json:"checkedAt,omitempty"`
// Messaging limit.
Split *WhatsAppLimitSplit `json:"split,omitempty"`
// Cost.
Cost *WhatsAppCost `json:"cost,omitempty"`
// Approval.
Author string `json:"author,omitempty"`
Missing []string `json:"missing"`
Helpers []string `json:"helpers"`
}
WhatsAppCheck is one pre-send check.
type WhatsAppConnectInput ¶
type WhatsAppConnectInput struct {
BusinessAccountID string `json:"businessAccountId" minLength:"1" maxLength:"40" doc:"The WhatsApp Business Account ID"`
PhoneNumberID string `json:"phoneNumberId" minLength:"1" maxLength:"40"`
AccessToken string `json:"accessToken" minLength:"1" maxLength:"1024" doc:"A system user's permanent access token"`
AppSecret string `json:"appSecret" minLength:"1" maxLength:"200" doc:"The app secret Meta signs webhooks with"`
}
WhatsAppConnectInput connects an account. Every value is write-only.
type WhatsAppConsentEvidence ¶
type WhatsAppConsentEvidence struct {
ConsentText string `json:"consentText" maxLength:"1000"`
ConsentVersion string `json:"consentVersion,omitempty" maxLength:"40"`
Source string `json:"source" maxLength:"200" doc:"Where it was given: a form, a call, an event"`
Page string `json:"page,omitempty" maxLength:"500"`
IP string `json:"ip,omitempty" maxLength:"45"`
At time.Time `json:"at"`
}
WhatsAppConsentEvidence is what a person's consent was given with.
type WhatsAppConsentInput ¶
type WhatsAppConsentInput struct {
ListID string `json:"listId" format:"uuid"`
Status string `json:"status" enum:"subscribed,not_subscribed"`
Evidence *WhatsAppConsentEvidence `json:"evidence,omitempty"`
Note string `json:"note,omitempty" maxLength:"500"`
}
WhatsAppConsentInput changes a contact's WhatsApp consent on a list.
type WhatsAppContactCard ¶
type WhatsAppContactCard struct {
Connected bool `json:"connected"`
Name string `json:"name"`
Email string `json:"email"`
Phone string `json:"phone"`
Display string `json:"display"`
Country string `json:"country"`
LineType string `json:"lineType"`
TimeZone string `json:"timeZone"`
Lists []WhatsAppContactList `json:"lists"`
Suppressed *WhatsAppSuppression `json:"suppressed,omitempty"`
Window WhatsAppWindow `json:"window"`
Thread []WhatsAppThreadItem `json:"thread"`
Business *WhatsAppBusiness `json:"business,omitempty"`
CanEdit bool `json:"canEdit"`
// CanReply: the window is open, the account sends and the viewer holds
// whatsapp:send.
CanReply bool `json:"canReply"`
}
WhatsAppContactCard is the contact profile's WhatsApp card.
type WhatsAppContactList ¶
type WhatsAppContactList struct {
ListID string `json:"listId"`
Name string `json:"name"`
Status string `json:"status" enum:"subscribed,pending,opted_out,not_subscribed"`
At *time.Time `json:"at,omitempty"`
Source string `json:"source"`
Keyword string `json:"keyword,omitempty"`
// Page and Version are the evidence's: where and with which text.
Page string `json:"page,omitempty"`
Version string `json:"version,omitempty"`
}
WhatsAppContactList is a list's WhatsApp consent.
type WhatsAppContactPath ¶
type WhatsAppContactPath struct {
api.WorkspaceInput
ContactID string `path:"contactId" format:"uuid" doc:"Contact id"`
}
WhatsAppContactPath names a contact.
type WhatsAppCost ¶
type WhatsAppCost struct {
Amount float64 `json:"amount"`
Messages int64 `json:"messages"`
Category string `json:"category"`
RatesAsOf time.Time `json:"ratesAsOf"`
ByCountry []WhatsAppCostCountry `json:"byCountry"`
}
WhatsAppCost is an estimate.
type WhatsAppCostCountry ¶
type WhatsAppCostCountry struct {
Country string `json:"country"`
Messages int64 `json:"messages"`
Price float64 `json:"price"`
Amount float64 `json:"amount"`
}
WhatsAppCostCountry is a country's part of an estimate.
type WhatsAppCredentialsInput ¶
type WhatsAppCredentialsInput struct {
BusinessAccountID string `json:"businessAccountId,omitempty" maxLength:"40"`
PhoneNumberID string `json:"phoneNumberId,omitempty" maxLength:"40"`
AccessToken string `json:"accessToken,omitempty" maxLength:"1024"`
AppSecret string `json:"appSecret,omitempty" maxLength:"200"`
}
WhatsAppCredentialsInput replaces credentials: a new access token (Reconnect), and the other values when they changed. Empty keeps one.
type WhatsAppEstimate ¶
type WhatsAppEstimate struct {
Consent int64 `json:"consent"`
Cost WhatsAppCost `json:"cost"`
Connected bool `json:"connected"`
Quiet bool `json:"quiet"`
Window string `json:"window"`
// Open is how many of them can get free text now (they wrote in the
// last 24 hours).
Open int64 `json:"open"`
}
WhatsAppEstimate is who a WhatsApp step or campaign on a list reaches and what it costs.
type WhatsAppEvent ¶
type WhatsAppEvent struct {
ID string `json:"id"`
ReceivedAt time.Time `json:"receivedAt"`
Summary string `json:"summary"`
SignatureOK bool `json:"signatureOk"`
NormalizedAt *time.Time `json:"normalizedAt,omitempty"`
Events int `json:"events"`
Error string `json:"error,omitempty"`
// Kind is what it was about; Number the person's number, masked
// (+1 312 ••• 0123); Status a message status or a template's.
Kind string `json:"kind" enum:"status,message,template,quality,account,unknown"`
Number string `json:"number,omitempty"`
Status string `json:"status,omitempty"`
Code int `json:"code,omitempty"`
}
WhatsAppEvent is a webhook as Meta sent it, and what came of it.
type WhatsAppEventList ¶
type WhatsAppEventList struct {
Items []WhatsAppEvent `json:"items"`
// Next is the time to ask for the page after this one.
Next *time.Time `json:"next,omitempty"`
}
WhatsAppEventList is a page of events, newest first.
type WhatsAppFailure ¶
type WhatsAppFailure struct {
Reason string `json:"reason"`
Code string `json:"code"`
Count int64 `json:"count"`
}
WhatsAppFailure is a reason messages failed for.
type WhatsAppFallback ¶
type WhatsAppFallback struct {
Key string `json:"key"`
Field string `json:"field"`
Fallback string `json:"fallback"`
}
WhatsAppFallback is a variable's fallback as the preview explains it.
type WhatsAppField ¶
WhatsAppField is a contact field a variable can take.
type WhatsAppLimitSplit ¶
type WhatsAppLimitSplit struct {
Limit int64 `json:"limit"`
// Used is how many people got a message the business started in the
// rolling 24 hours; Left how many more it can start.
Used int64 `json:"used"`
Left int64 `json:"left"`
// Now get it now (or at their time); Later the next day from LaterAt.
Now int64 `json:"now"`
Later int64 `json:"later"`
LaterAt *time.Time `json:"laterAt,omitempty"`
// UsedBy is the send that used most of the limit: its name and time.
UsedBy string `json:"usedBy,omitempty"`
UsedByAt *time.Time `json:"usedByAt,omitempty"`
UsedByN int64 `json:"usedByN,omitempty"`
}
WhatsAppLimitSplit is how a send fits the messaging limit.
type WhatsAppListConsent ¶
type WhatsAppListConsent struct {
ListID string `json:"listId"`
Name string `json:"name"`
Consent int64 `json:"consent"`
Members int64 `json:"members"`
}
WhatsAppListConsent is a list's people with WhatsApp consent.
type WhatsAppOverview ¶
type WhatsAppOverview struct {
Account *WhatsAppAccount `json:"account,omitempty"`
Templates []WhatsAppTemplate `json:"templates"`
TemplateCounts WhatsAppTemplateCounts `json:"templateCounts"`
Consent int64 `json:"consent"`
ConsentLists []WhatsAppListConsent `json:"consentLists"`
RatesAsOf time.Time `json:"ratesAsOf"`
Quiet bool `json:"quiet"`
Window string `json:"window"`
// SameWindowAsSMS is true once the workspace has SMS rules: the
// window is theirs.
SameWindowAsSMS bool `json:"sameWindowAsSms"`
// WebhookURL is where Meta posts (shown before connecting too).
WebhookURL string `json:"webhookUrl"`
// TestNumbers are the member's numbers for tests.
TestNumbers []string `json:"testNumbers"`
CanManage bool `json:"canManage"`
CanSend bool `json:"canSend"`
Helpers []string `json:"helpers"`
}
WhatsAppOverview is Sending providers › WhatsApp.
type WhatsAppPreview ¶
type WhatsAppPreview struct {
ContactID string `json:"contactId,omitempty"`
Contact string `json:"contact"`
FirstName string `json:"firstName,omitempty"`
Text string `json:"text"`
Buttons []WhatsAppTemplateButton `json:"buttons"`
// Fallbacks are the variables that used their fallback for this
// contact, and what someone without the field reads.
Fallbacks []WhatsAppFallback `json:"fallbacks"`
}
WhatsAppPreview is the chat preview as one contact.
type WhatsAppRate ¶
type WhatsAppRate struct {
Country string `json:"country" pattern:"^([A-Z]{2}|\\*)$"`
Category string `json:"category" enum:"marketing,utility,authentication"`
Price float64 `json:"price" minimum:"0" maximum:"10"`
}
WhatsAppRate is one price of the rate card: per delivered message, in USD. Country "*" is every other country.
type WhatsAppRates ¶
type WhatsAppRates struct {
AsOf time.Time `json:"asOf"`
Rates []WhatsAppRate `json:"rates"`
EditedBy string `json:"editedBy,omitempty"`
EditedAt *time.Time `json:"editedAt,omitempty"`
CanManage bool `json:"canManage"`
}
WhatsAppRates is the rate card as the Edit rates dialog shows it.
type WhatsAppRatesInput ¶
type WhatsAppRatesInput struct {
AsOf string `json:"asOf" pattern:"^\\d{4}-\\d{2}-\\d{2}$" doc:"The card's date (YYYY-MM-DD)"`
Rates []WhatsAppRate `json:"rates" minItems:"1" maxItems:"600"`
}
WhatsAppRatesInput replaces the rate card.
type WhatsAppReplyInput ¶
type WhatsAppReplyInput struct {
Text string `json:"text" minLength:"1" maxLength:"4096"`
}
WhatsAppReplyInput is a free-form reply inside the window.
type WhatsAppReport ¶
type WhatsAppReport struct {
ID string `json:"id"`
Name string `json:"name"`
Status string `json:"status" enum:"draft,approval,approved,scheduled,sending,paused,sent,cancelled,failed"`
SentAt *time.Time `json:"sentAt,omitempty"`
SentBy string `json:"sentBy"`
Template string `json:"template"`
Category string `json:"category"`
// Planned is everyone the send was for; Skipped those left out, by
// reason; Queued those not sent yet (the next day's share of the
// limit among them).
Planned int64 `json:"planned"`
Skipped map[string]int64 `json:"skipped"`
Queued int64 `json:"queued"`
Held int64 `json:"held"`
Sent int64 `json:"sent"`
Delivered int64 `json:"delivered"`
DeliveredPct float64 `json:"deliveredPct"`
Read int64 `json:"read"`
ReadPct float64 `json:"readPct"`
Failed int64 `json:"failed"`
Failures []WhatsAppFailure `json:"failures"`
Buttons int64 `json:"buttons"`
Replies int64 `json:"replies"`
OptOuts int64 `json:"optOuts"`
Cost float64 `json:"cost"`
Estimate float64 `json:"estimate"`
ByCountry []WhatsAppReportCountry `json:"byCountry"`
RatesAsOf time.Time `json:"ratesAsOf"`
}
WhatsAppReport is a WhatsApp campaign's report.
type WhatsAppReportCountry ¶
type WhatsAppReportCountry struct {
Country string `json:"country"`
Sent int64 `json:"sent"`
Delivered int64 `json:"delivered"`
Read int64 `json:"read"`
Failed int64 `json:"failed"`
Cost float64 `json:"cost"`
}
WhatsAppReportCountry is a country's part.
type WhatsAppReview ¶
type WhatsAppReview struct {
ID string `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
Version int `json:"version"`
Verdict string `json:"verdict" enum:"ready,warnings,blocked"`
CheckedAt time.Time `json:"checkedAt"`
Checks []WhatsAppCheck `json:"checks"`
Audience WhatsAppAudience `json:"audience"`
Schedule WhatsAppSchedule `json:"schedule"`
OverLimit string `json:"overLimit" enum:"next_day,skip"`
Cost WhatsAppCost `json:"cost"`
Approval approvals.ReviewApproval `json:"approval"`
Access WhatsAppAccess `json:"access"`
Send *WhatsAppSendState `json:"send,omitempty"`
}
WhatsAppReview is Review & send.
type WhatsAppSchedule ¶
type WhatsAppSchedule struct {
// Mode: now; at one moment; local, a time in each recipient's zone.
Mode string `json:"mode" enum:"now,at,local"`
SendAt *time.Time `json:"sendAt,omitempty"`
// LocalDate (YYYY-MM-DD) and LocalMinute (540 = 09:00) for local.
LocalDate string `json:"localDate,omitempty"`
LocalMinute *int `json:"localMinute,omitempty"`
Label string `json:"label"`
}
WhatsAppSchedule is when a campaign goes.
type WhatsAppSendInput ¶
type WhatsAppSendInput struct {
// Version is the version Review & send showed; a newer one is refused.
Version int `json:"version" minimum:"1"`
// OverLimit is what happens to the people over the messaging limit:
// the next day (default) or skipped.
OverLimit string `json:"overLimit,omitempty" enum:"next_day,skip,"`
}
WhatsAppSendInput sends a campaign as reviewed.
type WhatsAppSendResult ¶
type WhatsAppSendResult struct {
Status string `json:"status" enum:"scheduled,sending"`
ScheduledAt time.Time `json:"scheduledAt"`
Recipients int64 `json:"recipients"`
Now int64 `json:"now"`
Later int64 `json:"later"`
}
WhatsAppSendResult is what Send did.
type WhatsAppSendState ¶
type WhatsAppSendState struct {
Phase string `json:"phase" enum:"scheduled,sending,completed,cancelled"`
ScheduledAt time.Time `json:"scheduledAt"`
Recipients int64 `json:"recipients"`
StartedBy string `json:"startedBy,omitempty"`
CompletedAt *time.Time `json:"completedAt,omitempty"`
}
WhatsAppSendState is a scheduled or running send.
type WhatsAppSettingsInput ¶
type WhatsAppSettingsInput struct {
QuietHours bool `json:"quietHours"`
}
WhatsAppSettingsInput is whether WhatsApp keeps to the quiet hours.
type WhatsAppStepEstimate ¶
type WhatsAppStepEstimate struct {
Connected bool `json:"connected"`
Business *WhatsAppBusiness `json:"business,omitempty"`
Templates []WhatsAppTemplate `json:"templates"`
Fields []WhatsAppField `json:"fields"`
// Consent counts the list's people with WhatsApp consent, a phone and
// no suppression; Open those who wrote in the last 24 hours.
Consent int64 `json:"consent"`
Open int64 `json:"open"`
Cost WhatsAppCost `json:"cost"`
Quiet bool `json:"quiet"`
Window string `json:"window"`
// Preview is the step's template as the list's most recent writer reads it.
Preview *WhatsAppPreview `json:"preview,omitempty"`
WindowExample *WhatsAppWindowExample `json:"windowExample,omitempty"`
}
WhatsAppStepEstimate is what the Send WhatsApp step's panel and its node on the canvas show (AutomationChannels): the account, the templates to pick, the fields variables take, who the step reaches on its list, what a template to them costs, a preview as one of them, and someone inside the customer service window.
type WhatsAppStepEstimateInput ¶
type WhatsAppStepEstimateInput struct {
ConsentListID string `json:"consentListId,omitempty" maxLength:"40"`
Mode string `json:"mode,omitempty" enum:"template,text,"`
Template string `json:"template,omitempty" maxLength:"512"`
Language string `json:"language,omitempty" maxLength:"16"`
Variables []automations.AutomationWhatsAppVar `json:"variables,omitempty" maxItems:"20"`
// FallbackTemplate is the template free text falls back to outside the window.
FallbackTemplate string `json:"fallbackTemplate,omitempty" maxLength:"512"`
}
WhatsAppStepEstimateInput is the Send WhatsApp step the panel shows.
type WhatsAppStepStats ¶
type WhatsAppStepStats struct {
NodeID string `json:"nodeId"`
Sent int64 `json:"sent"`
Delivered int64 `json:"delivered"`
Read int64 `json:"read"`
Failed int64 `json:"failed"`
Waiting int64 `json:"waiting"`
Skipped map[string]int64 `json:"skipped"`
Cost float64 `json:"cost"`
}
WhatsAppStepStats is one WhatsApp step's last 30 days.
type WhatsAppStepStatsList ¶
type WhatsAppStepStatsList struct {
Steps []WhatsAppStepStats `json:"steps"`
}
WhatsAppStepStatsList is a flow's WhatsApp steps.
type WhatsAppSuppression ¶
type WhatsAppSuppression struct {
Reason string `json:"reason"`
Keyword string `json:"keyword,omitempty"`
At time.Time `json:"at"`
}
WhatsAppSuppression is a number that gets no WhatsApp messages.
type WhatsAppSyncResult ¶
type WhatsAppSyncResult struct {
Templates int `json:"templates"`
Added []string `json:"added"`
Changed []string `json:"changed"`
Removed []string `json:"removed"`
SyncedAt time.Time `json:"syncedAt"`
}
WhatsAppSyncResult is what a sync found.
type WhatsAppTemplate ¶
type WhatsAppTemplate struct {
ID string `json:"id"`
Name string `json:"name"`
Language string `json:"language"`
LanguageLabel string `json:"languageLabel"`
Category string `json:"category" enum:"marketing,utility,authentication"`
Status string `json:"status" enum:"approved,pending,rejected,paused,disabled,in_appeal,other"`
StatusSince *time.Time `json:"statusSince,omitempty"`
Reason string `json:"reason,omitempty"`
ReasonCode string `json:"reasonCode,omitempty"`
Body string `json:"body"`
Variables []WhatsAppTemplateVar `json:"variables"`
Buttons []WhatsAppTemplateButton `json:"buttons"`
SyncedAt time.Time `json:"syncedAt"`
}
WhatsAppTemplate is a template as the Templates tab and the pickers show it.
type WhatsAppTemplateButton ¶
type WhatsAppTemplateButton struct {
Type string `json:"type" enum:"quick_reply,url,phone_number,other"`
Text string `json:"text"`
URL string `json:"url,omitempty"`
}
WhatsAppTemplateButton is a template's button.
type WhatsAppTemplateCounts ¶
type WhatsAppTemplateCounts struct {
Approved int `json:"approved"`
Pending int `json:"pending"`
Rejected int `json:"rejected"`
Other int `json:"other"`
}
WhatsAppTemplateCounts are the templates by status.
type WhatsAppTemplateVar ¶
type WhatsAppTemplateVar struct {
Key string `json:"key"`
Label string `json:"label"`
Example string `json:"example,omitempty"`
}
WhatsAppTemplateVar is a template variable: {{1}}, its label and Meta's sample value.
type WhatsAppTestInput ¶
type WhatsAppTestInput struct {
// Phone is the member's number, in any common format.
Phone string `json:"phone" minLength:"1" maxLength:"40"`
// TemplateID is the approved template to send; empty picks the first.
TemplateID string `json:"templateId,omitempty" maxLength:"40"`
}
WhatsAppTestInput sends a test to a member's WhatsApp.
type WhatsAppTestResult ¶
type WhatsAppTestResult struct {
ID string `json:"id"`
At time.Time `json:"at"`
To string `json:"to"`
Template string `json:"template"`
Status string `json:"status" enum:"queued,sending,sent,delivered,failed,held,cancelled,skipped,undelivered"`
Read bool `json:"read"`
Reason string `json:"reason,omitempty"`
}
WhatsAppTestResult is a test message and what Meta reported so far.
type WhatsAppThreadItem ¶
type WhatsAppThreadItem struct {
ID string `json:"id"`
Direction string `json:"direction" enum:"in,out"`
Kind string `json:"kind" enum:"template,text,reply,keyword,button"`
Text string `json:"text"`
Template string `json:"template,omitempty"`
At time.Time `json:"at"`
Status string `json:"status,omitempty"`
Read bool `json:"read"`
Campaign string `json:"campaign,omitempty"`
}
WhatsAppThreadItem is one message of the conversation.
type WhatsAppVariable ¶
type WhatsAppVariable struct {
Key string `json:"key" maxLength:"4"`
// Source is "field" or "text".
Source string `json:"source" enum:"field,text"`
Field string `json:"field,omitempty" maxLength:"64"`
Text string `json:"text,omitempty" maxLength:"500"`
Fallback string `json:"fallback,omitempty" maxLength:"500"`
}
WhatsAppVariable maps a template variable to a contact field or a fixed text, with a fallback.
type WhatsAppWindow ¶
type WhatsAppWindow struct {
Open bool `json:"open"`
// Until is when it closes (or closed): 24 hours after LastAt.
Until *time.Time `json:"until,omitempty"`
LastAt *time.Time `json:"lastAt,omitempty"`
LastText string `json:"lastText,omitempty"`
}
WhatsAppWindow is a number's customer service window.
type WhatsAppWindowExample ¶
WhatsAppWindowExample is someone the step's free text reaches now, and until when.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package meta talks to Meta's WhatsApp Cloud API over plain HTTP (design expansion phase 8, X22): the phone number and its quality rating and messaging limit, the business account, message templates, sending template and text messages, the webhook's verification handshake and its X-Hub-Signature-256, and the webhook payloads.
|
Package meta talks to Meta's WhatsApp Cloud API over plain HTTP (design expansion phase 8, X22): the phone number and its quality rating and messaging limit, the business account, message templates, sending template and text messages, the webhook's verification handshake and its X-Hub-Signature-256, and the webhook payloads. |
|
metatest
Package metatest is an in-process Graph API for WhatsApp, with recorded payloads: the phone number, the business account, message templates, sends and the webhook bodies Meta would post back.
|
Package metatest is an in-process Graph API for WhatsApp, with recorded payloads: the phone number, the business account, message templates, sends and the webhook bodies Meta would post back. |