import { automation } from "automate.ax"
import { resend } from "automate.ax/resend"
export default automation(
"Send the onboarding sequence",
{
parameters: [
{
label: "Onboarding segment ID",
name: "onboardingSegmentId",
type: "text",
},
{
label: "Onboarding topic ID",
name: "onboardingTopicId",
type: "text",
},
],
},
({ parameters }) => {
const enrolled = resend
.onContactEvent()
.filter(
({ event, segmentIds }) =>
(event.type === "contact.created" ||
event.type === "contact.updated") &&
segmentIds?.includes(parameters.onboardingSegmentId) === true,
)
resend.sendEmail({
from: "Onboarding <hello@example.com>",
to: enrolled.email,
subject: "Welcome",
text: "Welcome aboard!",
topicId: parameters.onboardingTopicId,
})
},
)