Back to jobs
Trigger: eventTrigger
Updates or creates customer information based on an identifier.
Integrations:
/src/plainUpdateCustomer
Databases
1import { Job, TriggerClient, eventTrigger } from "@trigger.dev/sdk";2import {3ComponentDividerSpacingSize,4ComponentTextColor,5ComponentTextSize,6Plain,7} from "@trigger.dev/plain";89const client = new TriggerClient({ id: "jobs-showcase" });1011export const plain = new Plain({12id: "plain",13apiKey: process.env.PLAIN_API_KEY!,14});1516// This Job will use update a customer's information in Plain based on an identifier.17client.defineJob({18id: "plain-update-customer",19name: "Plain: update customer",20version: "1.0.0",21integrations: {22plain,23},24trigger: eventTrigger({25name: "plain.update.customer",26}),27run: async (payload, io, ctx) => {28const { customer } = await io.plain.upsertCustomer("upsert-customer", {29identifier: {3031},32// If customer isn't found they should be created33onCreate: {34email: {3536isVerified: true,37},38fullName: "Rick Astley",39externalId: "u_123",40},41// If customer is found their details will be updated42onUpdate: {43fullName: {44value: "Rick Astley",45},46// This is the id of the customer in your own backend.47externalId: {48value: "u_123",49},50},51});52},53});5455// These lines can be removed if you don't want to use express56import { createExpressServer } from "@trigger.dev/express";57createExpressServer(client);