merge: resolve dev merge conflicts in package.json + lockfile
Kept uuid@^11.1.1 (feature branch version, newer than dev's ^11.0.5). Regenerated pnpm-lock.yaml. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -0,0 +1,200 @@
|
|||||||
|
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||||
|
|
||||||
|
const mockSendSms = vi.fn();
|
||||||
|
const mockGetDb = vi.fn();
|
||||||
|
const mockUuidv4 = vi.fn();
|
||||||
|
|
||||||
|
vi.mock("../../sms.js", () => ({
|
||||||
|
sendSms: mockSendSms,
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock("@groombook/db", () => ({
|
||||||
|
getDb: () => mockGetDb(),
|
||||||
|
conversations: {},
|
||||||
|
messages: {},
|
||||||
|
clients: {},
|
||||||
|
businessSettings: {},
|
||||||
|
eq: vi.fn((a, b) => [a, b]),
|
||||||
|
and: vi.fn((...args) => args),
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock("uuid", () => ({
|
||||||
|
v4: () => mockUuidv4(),
|
||||||
|
}));
|
||||||
|
|
||||||
|
const { sendMessage, MissingTenantPhoneNumberError } = await import("../outbound.js");
|
||||||
|
|
||||||
|
describe("sendMessage", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
vi.clearAllMocks();
|
||||||
|
mockUuidv4.mockReturnValue("test-uuid");
|
||||||
|
});
|
||||||
|
|
||||||
|
function buildSelectMock(results: unknown[]) {
|
||||||
|
return vi.fn().mockReturnValue({
|
||||||
|
from: vi.fn().mockReturnValue({
|
||||||
|
where: vi.fn().mockReturnValue({
|
||||||
|
limit: vi.fn().mockResolvedValue(results),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
it("returns suppressed=true when client has no phone", async () => {
|
||||||
|
mockGetDb.mockReturnValue({
|
||||||
|
select: buildSelectMock([{ phone: null, smsOptIn: true }]),
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await sendMessage({
|
||||||
|
businessId: "biz-1",
|
||||||
|
clientId: "client-1",
|
||||||
|
body: "Hello",
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result).toEqual({ suppressed: true });
|
||||||
|
expect(mockSendSms).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("returns suppressed=true when client has opted out of SMS", async () => {
|
||||||
|
mockGetDb.mockReturnValue({
|
||||||
|
select: buildSelectMock([{ phone: "+1234567890", smsOptIn: false }]),
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await sendMessage({
|
||||||
|
businessId: "biz-1",
|
||||||
|
clientId: "client-1",
|
||||||
|
body: "Hello",
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result).toEqual({ suppressed: true });
|
||||||
|
expect(mockSendSms).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("throws MissingTenantPhoneNumberError when tenant has no messaging phone", async () => {
|
||||||
|
mockGetDb.mockReturnValue({
|
||||||
|
select: vi
|
||||||
|
.fn()
|
||||||
|
.mockReturnValueOnce({
|
||||||
|
from: vi.fn().mockReturnValue({
|
||||||
|
where: vi.fn().mockReturnValue({
|
||||||
|
limit: vi.fn().mockResolvedValue([{ phone: "+1234567890", smsOptIn: true }]),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
.mockReturnValueOnce({
|
||||||
|
from: vi.fn().mockReturnValue({
|
||||||
|
where: vi.fn().mockReturnValue({
|
||||||
|
limit: vi.fn().mockResolvedValue([{ messagingPhoneNumber: null }]),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
sendMessage({ businessId: "biz-1", clientId: "client-1", body: "Hello" })
|
||||||
|
).rejects.toThrow(MissingTenantPhoneNumberError);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("persists provider message id on success", async () => {
|
||||||
|
const messageId = "msg-1";
|
||||||
|
const conversationId = "conv-1";
|
||||||
|
|
||||||
|
mockGetDb.mockReturnValue({
|
||||||
|
select: vi
|
||||||
|
.fn()
|
||||||
|
.mockReturnValueOnce({
|
||||||
|
from: vi.fn().mockReturnValue({
|
||||||
|
where: vi.fn().mockReturnValue({
|
||||||
|
limit: vi.fn().mockResolvedValue([{ phone: "+1234567890", smsOptIn: true }]),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
.mockReturnValueOnce({
|
||||||
|
from: vi.fn().mockReturnValue({
|
||||||
|
where: vi.fn().mockReturnValue({
|
||||||
|
limit: vi.fn().mockResolvedValue([{ messagingPhoneNumber: "+1987654321" }]),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
.mockReturnValueOnce({
|
||||||
|
from: vi.fn().mockReturnValue({
|
||||||
|
where: vi.fn().mockReturnValue({
|
||||||
|
limit: vi.fn().mockResolvedValue([{ id: conversationId }]),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
insert: vi.fn().mockReturnValue({
|
||||||
|
values: vi.fn().mockReturnValue({
|
||||||
|
returning: vi.fn().mockResolvedValue([{ id: messageId }]),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
update: vi.fn().mockReturnValue({
|
||||||
|
set: vi.fn().mockReturnValue({
|
||||||
|
where: vi.fn().mockResolvedValue([]),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
mockSendSms.mockResolvedValue({ messageId: "provider-msg-1", status: "sent" });
|
||||||
|
|
||||||
|
const result = await sendMessage({
|
||||||
|
businessId: "biz-1",
|
||||||
|
clientId: "client-1",
|
||||||
|
body: "Hello",
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result).toEqual({
|
||||||
|
messageId,
|
||||||
|
providerMessageId: "provider-msg-1",
|
||||||
|
status: "sent",
|
||||||
|
suppressed: false,
|
||||||
|
});
|
||||||
|
expect(mockSendSms).toHaveBeenCalledWith("+1234567890", "Hello", undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("persists error on Telnyx failure", async () => {
|
||||||
|
const messageId = "msg-1";
|
||||||
|
|
||||||
|
mockGetDb.mockReturnValue({
|
||||||
|
select: vi
|
||||||
|
.fn()
|
||||||
|
.mockReturnValueOnce({
|
||||||
|
from: vi.fn().mockReturnValue({
|
||||||
|
where: vi.fn().mockReturnValue({
|
||||||
|
limit: vi.fn().mockResolvedValue([{ phone: "+1234567890", smsOptIn: true }]),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
.mockReturnValueOnce({
|
||||||
|
from: vi.fn().mockReturnValue({
|
||||||
|
where: vi.fn().mockReturnValue({
|
||||||
|
limit: vi.fn().mockResolvedValue([{ messagingPhoneNumber: "+1987654321" }]),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
.mockReturnValueOnce({
|
||||||
|
from: vi.fn().mockReturnValue({
|
||||||
|
where: vi.fn().mockReturnValue({
|
||||||
|
limit: vi.fn().mockResolvedValue([]),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
insert: vi.fn().mockReturnValue({
|
||||||
|
values: vi.fn().mockReturnValue({
|
||||||
|
returning: vi.fn().mockResolvedValue([{ id: messageId }]),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
update: vi.fn().mockReturnValue({
|
||||||
|
set: vi.fn().mockReturnValue({
|
||||||
|
where: vi.fn().mockResolvedValue([]),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
mockSendSms.mockRejectedValue(new Error("Telnyx API error"));
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
sendMessage({ businessId: "biz-1", clientId: "client-1", body: "Hello" })
|
||||||
|
).rejects.toThrow("Telnyx API error");
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,159 @@
|
|||||||
|
import { getDb, conversations, messages, clients, businessSettings, eq, and } from "@groombook/db";
|
||||||
|
import { v4 as uuidv4 } from "uuid";
|
||||||
|
import { sendSms } from "../sms.js";
|
||||||
|
|
||||||
|
export interface SendMessageOptions {
|
||||||
|
businessId: string;
|
||||||
|
clientId: string;
|
||||||
|
body: string;
|
||||||
|
sentByStaffId?: string;
|
||||||
|
mediaUrls?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SendMessageResult {
|
||||||
|
messageId: string;
|
||||||
|
providerMessageId: string;
|
||||||
|
status: string;
|
||||||
|
suppressed: false;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SendMessageSuppressed {
|
||||||
|
suppressed: true;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SendMessageResponse = SendMessageResult | SendMessageSuppressed;
|
||||||
|
|
||||||
|
export class MissingTenantPhoneNumberError extends Error {
|
||||||
|
constructor() {
|
||||||
|
super("Tenant messagingPhoneNumber is not configured");
|
||||||
|
this.name = "MissingTenantPhoneNumberError";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function findOrCreateConversation(
|
||||||
|
businessId: string,
|
||||||
|
clientId: string,
|
||||||
|
externalNumber: string,
|
||||||
|
businessNumber: string
|
||||||
|
): Promise<{ id: string }> {
|
||||||
|
const db = getDb();
|
||||||
|
|
||||||
|
const [existing] = await db
|
||||||
|
.select({ id: conversations.id })
|
||||||
|
.from(conversations)
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
eq(conversations.businessId, businessId),
|
||||||
|
eq(conversations.externalNumber, externalNumber),
|
||||||
|
eq(conversations.businessNumber, businessNumber)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
if (existing) return { id: existing.id };
|
||||||
|
|
||||||
|
const [created] = await db
|
||||||
|
.insert(conversations)
|
||||||
|
.values({
|
||||||
|
id: uuidv4(),
|
||||||
|
businessId,
|
||||||
|
clientId,
|
||||||
|
channel: "sms",
|
||||||
|
externalNumber,
|
||||||
|
businessNumber,
|
||||||
|
lastMessageAt: new Date(),
|
||||||
|
status: "active",
|
||||||
|
})
|
||||||
|
.returning({ id: conversations.id });
|
||||||
|
|
||||||
|
if (!created) throw new Error("Failed to create conversation");
|
||||||
|
|
||||||
|
return { id: created.id };
|
||||||
|
}
|
||||||
|
|
||||||
|
async function resolveFromNumber(businessId: string): Promise<string | null> {
|
||||||
|
const db = getDb();
|
||||||
|
const [settings] = await db
|
||||||
|
.select({ messagingPhoneNumber: businessSettings.messagingPhoneNumber })
|
||||||
|
.from(businessSettings)
|
||||||
|
.where(eq(businessSettings.id, businessId))
|
||||||
|
.limit(1);
|
||||||
|
return settings?.messagingPhoneNumber ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function sendMessage(opts: SendMessageOptions): Promise<SendMessageResponse> {
|
||||||
|
const db = getDb();
|
||||||
|
const { businessId, clientId, body, sentByStaffId, mediaUrls } = opts;
|
||||||
|
|
||||||
|
const [client] = await db
|
||||||
|
.select({ phone: clients.phone, smsOptIn: clients.smsOptIn })
|
||||||
|
.from(clients)
|
||||||
|
.where(eq(clients.id, clientId))
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
if (!client?.phone) {
|
||||||
|
return { suppressed: true };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!client.smsOptIn) {
|
||||||
|
return { suppressed: true };
|
||||||
|
}
|
||||||
|
|
||||||
|
const from = await resolveFromNumber(businessId);
|
||||||
|
if (!from) throw new MissingTenantPhoneNumberError();
|
||||||
|
|
||||||
|
const to = client.phone;
|
||||||
|
const conversationId = (await findOrCreateConversation(businessId, clientId, to, from)).id;
|
||||||
|
|
||||||
|
const [queuedMessage] = await db
|
||||||
|
.insert(messages)
|
||||||
|
.values({
|
||||||
|
id: uuidv4(),
|
||||||
|
conversationId,
|
||||||
|
direction: "outbound",
|
||||||
|
body,
|
||||||
|
status: "queued",
|
||||||
|
sentByStaffId: sentByStaffId ?? null,
|
||||||
|
})
|
||||||
|
.returning({ id: messages.id });
|
||||||
|
|
||||||
|
if (!queuedMessage) throw new Error("Failed to insert queued message");
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await sendSms(to, body, mediaUrls);
|
||||||
|
|
||||||
|
await db
|
||||||
|
.update(messages)
|
||||||
|
.set({
|
||||||
|
status: "sent",
|
||||||
|
providerMessageId: result.messageId,
|
||||||
|
})
|
||||||
|
.where(eq(messages.id, queuedMessage.id));
|
||||||
|
|
||||||
|
await db
|
||||||
|
.update(conversations)
|
||||||
|
.set({ lastMessageAt: new Date() })
|
||||||
|
.where(eq(conversations.id, conversationId));
|
||||||
|
|
||||||
|
return {
|
||||||
|
messageId: queuedMessage.id,
|
||||||
|
providerMessageId: result.messageId,
|
||||||
|
status: result.status,
|
||||||
|
suppressed: false,
|
||||||
|
};
|
||||||
|
} catch (err) {
|
||||||
|
const errorCode = err instanceof Error ? err.name : "UNKNOWN";
|
||||||
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
||||||
|
|
||||||
|
await db
|
||||||
|
.update(messages)
|
||||||
|
.set({
|
||||||
|
status: "failed",
|
||||||
|
errorCode,
|
||||||
|
errorMessage,
|
||||||
|
})
|
||||||
|
.where(eq(messages.id, queuedMessage.id));
|
||||||
|
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -72,9 +72,15 @@ test.describe("Portal Data Integrity", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("billing section renders without JS errors", async ({ page }) => {
|
test("billing section renders without JS errors", async ({ page }) => {
|
||||||
// Mock billing endpoint
|
// Mock portal billing endpoints
|
||||||
await page.route("**/api/billing**", (route) =>
|
await page.route("**/api/portal/config**", (route) =>
|
||||||
route.fulfill({ json: { invoices: [], balanceCents: 0 } })
|
route.fulfill({ json: { stripePublishableKey: "" } })
|
||||||
|
);
|
||||||
|
await page.route("**/api/portal/invoices**", (route) =>
|
||||||
|
route.fulfill({ json: [] })
|
||||||
|
);
|
||||||
|
await page.route("**/api/portal/payment-methods**", (route) =>
|
||||||
|
route.fulfill({ json: [] })
|
||||||
);
|
);
|
||||||
|
|
||||||
const consoleErrors: string[] = [];
|
const consoleErrors: string[] = [];
|
||||||
|
|||||||
@@ -82,3 +82,13 @@ input:focus, select:focus, textarea:focus {
|
|||||||
::-webkit-scrollbar-thumb:hover {
|
::-webkit-scrollbar-thumb:hover {
|
||||||
background: #94a3b8;
|
background: #94a3b8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ─── Scrollbar hide utility ─── */
|
||||||
|
.scrollbar-hide {
|
||||||
|
-ms-overflow-style: none;
|
||||||
|
scrollbar-width: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.scrollbar-hide::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ function BillingPaymentsInner({ sessionId, readOnly }: BillingPaymentsProps) {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="flex gap-2 flex-wrap overflow-x-auto">
|
<div className="flex gap-2 overflow-x-auto scrollbar-hide">
|
||||||
{([
|
{([
|
||||||
{ id: "invoices" as const, label: "Invoices", icon: DollarSign },
|
{ id: "invoices" as const, label: "Invoices", icon: DollarSign },
|
||||||
{ id: "payment" as const, label: "Payment Methods", icon: CreditCard },
|
{ id: "payment" as const, label: "Payment Methods", icon: CreditCard },
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ export function PetProfiles({ sessionId, readOnly }: Props) {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Tabs */}
|
{/* Tabs */}
|
||||||
<div className="flex gap-1 bg-white rounded-xl border border-stone-200 p-1 overflow-x-auto">
|
<div className="flex gap-1 bg-white rounded-xl border border-stone-200 p-1 overflow-x-auto scrollbar-hide">
|
||||||
{([
|
{([
|
||||||
{ id: "info", label: "Basic Info", icon: PawPrint },
|
{ id: "info", label: "Basic Info", icon: PawPrint },
|
||||||
{ id: "medical", label: "Medical", icon: Heart },
|
{ id: "medical", label: "Medical", icon: Heart },
|
||||||
|
|||||||
@@ -0,0 +1,309 @@
|
|||||||
|
# 10DLC Pilot Tenant Registration Runbook
|
||||||
|
|
||||||
|
Authored for GRO-106 Phase 1.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Pre-Flight Checklist
|
||||||
|
|
||||||
|
Before starting Telnyx registration, collect the following:
|
||||||
|
|
||||||
|
| Item | Details |
|
||||||
|
|------|---------|
|
||||||
|
| Legal business name | Exact name on EIN / business registration |
|
||||||
|
| EIN (Employer Identification Number) | 9-digit IRS format: XX-XXXXXXX |
|
||||||
|
| Business type | Sole Proprietor / LLC / Corporation |
|
||||||
|
| Primary contact email | General contact address (postmaster@, info@, etc.) |
|
||||||
|
| Primary contact phone | Direct line for carrier verification |
|
||||||
|
| Website URL | Must be live and contain privacy policy |
|
||||||
|
| Sample message templates | See [Sample Templates](#sample-message-templates) below |
|
||||||
|
| Messaging use case | Customer Care / Account Notification |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Step 1 — Telnyx Account Requirements
|
||||||
|
|
||||||
|
- Active Telnyx account with billing configured.
|
||||||
|
- Role required: **Admin** or **Super User** to register brands and campaigns.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Step 2 — Brand Registration
|
||||||
|
|
||||||
|
### Via Telnyx Console
|
||||||
|
|
||||||
|
1. Log in to [Telnyx Portal](https://portal.telnyx.com).
|
||||||
|
2. Navigate to **Messaging → A2P 10DLC → Brands**.
|
||||||
|
3. Click **Register Brand**.
|
||||||
|
4. Fill in:
|
||||||
|
- **Brand Name**: Legal business name
|
||||||
|
- **Legal Company Name**: Exact EIN name
|
||||||
|
- **Company Type**: Select from dropdown
|
||||||
|
- **EIN**: XX-XXXXXXX
|
||||||
|
- **Primary Contact**: Name, email, phone
|
||||||
|
- **Website**: Must be accessible
|
||||||
|
- **BusinessVertical**: Select appropriate vertical
|
||||||
|
5. Acknowledge the **Terms of Service**.
|
||||||
|
6. Submit.
|
||||||
|
|
||||||
|
### Via API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -X POST https://api.telnyx.com/v2/10dlc/brands \
|
||||||
|
-H "Authorization: Bearer $TELNYX_API_KEY" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{
|
||||||
|
"name": "Your Legal Business Name",
|
||||||
|
"legal_company_name": "Your Legal Business Name",
|
||||||
|
"company_type": "llc",
|
||||||
|
"ein": "XX-XXXXXXX",
|
||||||
|
"primary_contact": {
|
||||||
|
"name": "Jane Doe",
|
||||||
|
"email": "compliance@example.com",
|
||||||
|
"phone": "+1XXXXXXXXXX"
|
||||||
|
},
|
||||||
|
"website": "https://www.example.com",
|
||||||
|
"business_vertical": "PROFESSIONAL_SERVICES"
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
**Response fields to record:**
|
||||||
|
- `brand_id` — required for campaign registration
|
||||||
|
- `brand_score` — affects campaign vetting speed
|
||||||
|
|
||||||
|
### Expected Fees
|
||||||
|
|
||||||
|
| Fee Type | Amount |
|
||||||
|
|----------|--------|
|
||||||
|
| Brand registration fee | ~$0 (no direct fee from Telnyx) |
|
||||||
|
| Campaign registration fee | ~$15–$25 per campaign (Telnyx fee, subject to change) |
|
||||||
|
| Carrier fees | Passed through from T-Mobile/AT&T/Verizon |
|
||||||
|
|
||||||
|
### Expected Approval Window
|
||||||
|
|
||||||
|
- **Vetting by Telnyx**: 1–3 business days after submission.
|
||||||
|
- **Carrier (T-Mobile/AT&T/Verizon) review**: 2–5 business days after Telnyx approval.
|
||||||
|
- Total end-to-end: **3–8 business days**.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Step 3 — Campaign Registration
|
||||||
|
|
||||||
|
### Use Case Selection
|
||||||
|
|
||||||
|
- **Primary**: Customer Care
|
||||||
|
- **Secondary**: Account Notification
|
||||||
|
|
||||||
|
### Via Telnyx Console
|
||||||
|
|
||||||
|
1. Navigate to **Messaging → A2P 10DLC → Campaigns**.
|
||||||
|
2. Click **Register Campaign**.
|
||||||
|
3. Select **Brand** (use the brand registered in Step 2).
|
||||||
|
4. Fill in:
|
||||||
|
- **Campaign Name**: e.g., `groombook-pilot-customer-care`
|
||||||
|
- **Use Case**: Customer Care / Account Notification
|
||||||
|
- **Sample Messages**: Paste exactly the templates from [Sample Templates](#sample-message-templates) below.
|
||||||
|
- **Description**: Brief description of messaging program
|
||||||
|
- **Estimated Volume**: Enter monthly estimate (e.g., 500)
|
||||||
|
5. Submit.
|
||||||
|
|
||||||
|
### Via API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -X POST https://api.telnyx.com/v2/10dlc/campaigns \
|
||||||
|
-H "Authorization: Bearer $TELNYX_API_KEY" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{
|
||||||
|
"brand_id": "YOUR_BRAND_ID",
|
||||||
|
"name": "groombook-pilot-customer-care",
|
||||||
|
"use_case": "CUSTOMER_CARE",
|
||||||
|
"sample_messages": [
|
||||||
|
"Hi {{first_name}}, this is a reminder from {{business_name}} that your appointment is scheduled for {{date}} at {{time}}. Reply STOP to opt out.",
|
||||||
|
"Your appointment with {{business_name}} is confirmed for {{date}}. Need to reschedule? Reply HELP or call us at {{phone}}."
|
||||||
|
],
|
||||||
|
"description": "Appointment reminders and account notifications for grooming clients",
|
||||||
|
"estimated_monthly_volume": 500
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
**Response fields to record:**
|
||||||
|
- `campaign_id` — required for messaging profile
|
||||||
|
- `status` — initially `PENDING`, transitions to `ACTIVE` after carrier approval
|
||||||
|
|
||||||
|
### Campaign Vetting — STOP/HELP Language Requirements
|
||||||
|
|
||||||
|
Every campaign **must** include compliant STOP/HELP messaging. The following must appear in your sample messages or be included in your terms of service:
|
||||||
|
|
||||||
|
- **STOP**: Users can text `STOP` to opt out of all messages.
|
||||||
|
- **HELP**: Users can text `HELP` to receive contact information.
|
||||||
|
|
||||||
|
Example STOP/HELP block:
|
||||||
|
|
||||||
|
```
|
||||||
|
Text STOP to opt out. Text HELP for help. Msg & data rates may apply.
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Step 4 — Messaging Profile + Phone Number Provisioning
|
||||||
|
|
||||||
|
### Create Messaging Profile
|
||||||
|
|
||||||
|
1. In Telnyx Portal, navigate to **Messaging → Messaging Profiles**.
|
||||||
|
2. Click **Create Messaging Profile**.
|
||||||
|
3. Name it (e.g., `groombook-pilot-prod`).
|
||||||
|
4. Copy the **Messaging Profile ID** (`messaging_profile_id`) — record this in the DB.
|
||||||
|
|
||||||
|
### Provision a 10DLC Phone Number
|
||||||
|
|
||||||
|
1. Navigate to **Messaging → Phone Numbers**.
|
||||||
|
2. Search for a number in your desired area code.
|
||||||
|
3. Confirm the number is 10DLC-capable.
|
||||||
|
4. Purchase the number.
|
||||||
|
|
||||||
|
### Associate Number with Messaging Profile
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Assign number to messaging profile
|
||||||
|
curl -X PATCH https://api.telnyx.com/v2/phone_numbers/YOUR_PHONE_NUMBER_ID \
|
||||||
|
-H "Authorization: Bearer $TELNYX_API_KEY" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{
|
||||||
|
"messaging_profile_id": "YOUR_MESSAGING_PROFILE_ID"
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Step 5 — Record in Database
|
||||||
|
|
||||||
|
Once GRO-981 lands, record the following against the business record:
|
||||||
|
|
||||||
|
### SQL Path (when GRO-981 is complete)
|
||||||
|
|
||||||
|
```sql
|
||||||
|
UPDATE businesses
|
||||||
|
SET
|
||||||
|
messaging_phone_number = '+1XXXXXXXXXX',
|
||||||
|
telnyx_messaging_profile_id = 'YOUR_MESSAGING_PROFILE_ID',
|
||||||
|
telnyx_brand_id = 'YOUR_BRAND_ID',
|
||||||
|
telnyx_campaign_id = 'YOUR_CAMPAIGN_ID',
|
||||||
|
telnyx_brand_status = 'APPROVED',
|
||||||
|
telnyx_campaign_status = 'ACTIVE',
|
||||||
|
updated_at = NOW()
|
||||||
|
WHERE id = 'pilot_business_id';
|
||||||
|
```
|
||||||
|
|
||||||
|
### Manual Admin Path (before GRO-981)
|
||||||
|
|
||||||
|
Until GRO-981 is complete, use the Telnyx Portal to verify and record values manually in your internal ops sheet:
|
||||||
|
|
||||||
|
| Field | Value |
|
||||||
|
|-------|-------|
|
||||||
|
| `messagingPhoneNumber` | +1XXXXXXXXXX |
|
||||||
|
| `telnyxMessagingProfileId` | xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx |
|
||||||
|
| `telnyxBrandId` | xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx |
|
||||||
|
| `telnyxCampaignId` | xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx |
|
||||||
|
| `brandStatus` | APPROVED / PENDING |
|
||||||
|
| `campaignStatus` | ACTIVE / PENDING |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Sample Message Templates
|
||||||
|
|
||||||
|
These must match exactly what your system will send. Vetting reviewers compare templates against actual traffic.
|
||||||
|
|
||||||
|
### Transactional Appointment Reminder
|
||||||
|
|
||||||
|
```
|
||||||
|
Hi {{first_name}}, this is a reminder from {{business_name}} that your appointment is scheduled for {{date}} at {{time}}. Reply STOP to opt out. Msg & data rates may apply.
|
||||||
|
```
|
||||||
|
|
||||||
|
### Manual Staff Message
|
||||||
|
|
||||||
|
```
|
||||||
|
Your appointment with {{business_name}} is confirmed for {{date}}. Need to reschedule? Reply HELP for assistance or call us at {{phone}}. Msg & data rates may apply.
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Failure Modes + Retry Guidance
|
||||||
|
|
||||||
|
### Vetting Rejection — Brand
|
||||||
|
|
||||||
|
| Rejection Reason | Common Fix |
|
||||||
|
|-----------------|------------|
|
||||||
|
| Legal name mismatch with EIN | Ensure exact EIN name matches legal company name exactly |
|
||||||
|
| Website not accessible / missing privacy policy | Add privacy policy page to website before resubmitting |
|
||||||
|
| Incomplete primary contact | Provide direct phone and real email (no noreply) |
|
||||||
|
| High-risk business vertical | Contact Telnyx support for pre-screening before resubmitting |
|
||||||
|
|
||||||
|
### Campaign Rejection
|
||||||
|
|
||||||
|
| Rejection Reason | Common Fix |
|
||||||
|
|-----------------|------------|
|
||||||
|
| Sample messages do not match actual traffic | Update sample messages to match exactly what the system sends |
|
||||||
|
| Missing STOP/HELP language | Add compliant STOP/HELP block to sample messages |
|
||||||
|
| Volume estimate too low/high | Revise estimate to be realistic |
|
||||||
|
| Use case mismatch | Re-select use case that matches actual messaging |
|
||||||
|
|
||||||
|
### Re-submission
|
||||||
|
|
||||||
|
After fixing the rejection reason, re-submit via the same API endpoint. Telnyx will re-run vetting (typically 24–48 hours).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Cost Summary
|
||||||
|
|
||||||
|
### Telnyx Fees (as of 2026)
|
||||||
|
|
||||||
|
| Fee Type | Amount | Notes |
|
||||||
|
|----------|--------|-------|
|
||||||
|
| 10DLC number (monthly) | ~$1.00–$2.50/number | Varies by type and area code |
|
||||||
|
| Outbound message | $0.005–$0.015/message | Depends on destination carrier |
|
||||||
|
| Inbound message | Included | No charge for received messages |
|
||||||
|
| Campaign registration | ~$15–$25 one-time | Per campaign, subject to change |
|
||||||
|
|
||||||
|
### Carrier Fees (T-Mobile / AT&T / Verizon)
|
||||||
|
|
||||||
|
| Carrier | Outbound Fee | Notes |
|
||||||
|
|---------|-------------|-------|
|
||||||
|
| T-Mobile | ~$0.005–$0.01/message | Varies by message size (segment) |
|
||||||
|
| AT&T | ~$0.005–$0.015/message | Varies by message size (segment) |
|
||||||
|
| Verizon | ~$0.005–$0.01/message | Varies by message size (segment) |
|
||||||
|
|
||||||
|
**Note**: Carrier fees are subject to change. Check [Telnyx pricing page](https://telnyx.com/pricing) and carrier fee schedules for current rates.
|
||||||
|
|
||||||
|
### Example Monthly Cost (Pilot — 500 messages/month)
|
||||||
|
|
||||||
|
| Line Item | Cost |
|
||||||
|
|-----------|------|
|
||||||
|
| 1x 10DLC number | ~$2.00 |
|
||||||
|
| 500 outbound messages | ~$5.00–$7.50 |
|
||||||
|
| Carrier pass-through | ~$2.50–$7.50 |
|
||||||
|
| **Estimated Monthly Total** | **~$9.50–$17.00** |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Rollback / De-provisioning
|
||||||
|
|
||||||
|
If the pilot tenant must be de-provisioned:
|
||||||
|
|
||||||
|
1. Release the phone number: Telnyx Portal → Phone Numbers → Release.
|
||||||
|
2. Archive the campaign: set status to `INACTIVE` via API or console.
|
||||||
|
3. Remove DB record: clear `messagingPhoneNumber`, `telnyxMessagingProfileId`, `telnyxCampaignId` fields in the business record.
|
||||||
|
4. Brand can remain registered (no harm) but will not be used.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Contacts
|
||||||
|
|
||||||
|
| Resource | Contact |
|
||||||
|
|----------|---------|
|
||||||
|
| Telnyx Support | support@telnyx.com |
|
||||||
|
| Telnyx Dashboard | portal.telnyx.com |
|
||||||
|
| Internal Engineering | Raise issue in GRO-106 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
_Owner: Engineering · Last updated: 2026-05-04_
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# GroomBook Runbooks
|
||||||
|
|
||||||
|
Operational runbooks for GroomBook staff and operators.
|
||||||
|
|
||||||
|
| Runbook | Description | Status |
|
||||||
|
|---------|-------------|--------|
|
||||||
|
| [10DLC Pilot Registration](./10dlc-pilot-registration.md) | Register a pilot grooming business as an A2P 10DLC brand + campaign on Telnyx | Active |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
_To add a runbook, create a markdown file in this directory and update this table._
|
||||||
Reference in New Issue
Block a user