Back to APIs

Manage customer support ticketing and responses.

Using our official Plain integration

Create any tasks possible with the Plain API.

Use io.runTask() and the official SDK or fetch.

Plain integration docs

Example code using Plain

Below is a working code example of how you can use Plain with Trigger.dev. These samples are open source and maintained by the community, you can copy and paste them into your own projects.

1
import { Plain } from "@trigger.dev/plain";
2
import { TriggerClient, eventTrigger } from "@trigger.dev/sdk";
3
4
export const plain = new Plain({
5
id: "plain",
6
apiKey: process.env.PLAIN_API_KEY!,
7
});
8
9
// This Job will use update a customer's information in Plain based on an identifier.
10
client.defineJob({
11
id: "plain-update-customer",
12
name: "Plain: update customer",
13
version: "1.0.0",
14
integrations: {
15
plain,
16
},
17
trigger: eventTrigger({
18
name: "plain.update.customer",
19
}),
20
run: async (payload, io, ctx) => {
21
const { customer } = await io.plain.upsertCustomer("upsert-customer", {
22
identifier: {
23
emailAddress: "[email protected]",
24
},
25
// If customer isn't found they should be created
26
onCreate: {
27
email: {
28
29
isVerified: true,
30
},
31
fullName: "Rick Astley",
32
externalId: "u_123",
33
},
34
// If customer is found their details will be updated
35
onUpdate: {
36
fullName: {
37
value: "Rick Astley",
38
},
39
// This is the id of the customer in your own backend.
40
externalId: {
41
value: "u_123",
42
},
43
},
44
});
45
},
46
});