Files
simstudioai--sim/apps/sim/triggers/sendblue/utils.ts
T
wehub-resource-sync d25d482dc2
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:20:55 +08:00

77 lines
3.9 KiB
TypeScript

import type { TriggerOutput } from '@/triggers/types'
export const sendblueTriggerOptions = [
{ label: 'Message Received', id: 'sendblue_message_received' },
{ label: 'Message Status Updated', id: 'sendblue_message_status_updated' },
]
export function sendblueSetupInstructions(eventType: string): string {
const instructions = [
'Copy the <strong>Webhook URL</strong> above.',
'Open your <a href="https://dashboard.sendblue.com" target="_blank" rel="noopener noreferrer">Sendblue dashboard</a> and go to <strong>Settings &gt; Webhooks</strong>.',
eventType === 'Message Received'
? 'Paste the Webhook URL into the <strong>Receive Webhook</strong> field to receive inbound messages.'
: 'Paste the Webhook URL into the <strong>Send / Status Webhook</strong> field to receive outbound message status updates. You can also pass it per-message as the <code>status_callback</code> parameter.',
'Save your webhook settings in Sendblue.',
]
return instructions
.map(
(instruction, index) =>
`<div class="mb-3"><strong>${index + 1}.</strong> ${instruction}</div>`
)
.join('')
}
/**
* Outputs shared by both Sendblue message webhooks. Inbound and outbound
* status callbacks use the same payload schema.
*/
export function buildSendblueOutputs(): Record<string, TriggerOutput> {
return {
account_email: { type: 'string', description: 'Email of the Sendblue account' },
content: { type: 'string', description: 'Message text content' },
media_url: { type: 'string', description: 'CDN link to attached media, if any' },
is_outbound: { type: 'boolean', description: 'True for outbound messages, false for inbound' },
status: {
type: 'string',
description: 'Message status (e.g., RECEIVED, QUEUED, SENT, DELIVERED, ERROR)',
},
error_code: { type: 'number', description: 'Error identifier, null if none' },
error_message: { type: 'string', description: 'Descriptive error text, null if none' },
error_reason: { type: 'string', description: 'Additional error context, null if none' },
error_detail: { type: 'string', description: 'Detailed error information, null if none' },
message_handle: {
type: 'string',
description: 'Sendblue message identifier (use to deduplicate)',
},
date_sent: { type: 'string', description: 'ISO 8601 creation timestamp' },
date_updated: { type: 'string', description: 'ISO 8601 last-update timestamp' },
from_number: { type: 'string', description: 'E.164 sender phone number' },
number: { type: 'string', description: 'E.164 recipient/counterparty phone number' },
to_number: { type: 'string', description: 'E.164 destination phone number' },
was_downgraded: {
type: 'boolean',
description: 'True if the recipient lacks iMessage support',
},
plan: { type: 'string', description: 'Account plan type' },
message_type: { type: 'string', description: 'Message category (e.g., message, group)' },
group_id: { type: 'string', description: 'Group identifier, null for non-group messages' },
participants: { type: 'array', description: 'Participant phone numbers for group messages' },
send_style: { type: 'string', description: 'Expressive style if applied' },
opted_out: { type: 'boolean', description: 'True if the recipient has opted out' },
sendblue_number: { type: 'string', description: 'Sendblue phone number used' },
service: { type: 'string', description: 'Messaging service (iMessage or SMS)' },
group_display_name: {
type: 'string',
description: 'Group chat name, null for non-group messages',
},
sender_email: { type: 'string', description: 'Email of the user who sent the message' },
seat_id: { type: 'string', description: 'Seat UUID, null if absent' },
raw: {
type: 'string',
description: 'Complete raw webhook payload from Sendblue as a JSON string',
},
}
}