1
import { TriggerClient } from "@trigger.dev/sdk";
2
import { Airtable } from "@trigger.dev/airtable";
3
import { Typeform } from "@trigger.dev/typeform";
4
const typeform = new Typeform({
6
token: process.env.TYPEFORM_TOKEN!,
9
const airtable = new Airtable({
11
token: process.env.AIRTABLE_TOKEN!,
19
emailContactEnabled: boolean;
24
id: "typeform-new-submission-update-airtable",
25
name: "On new Typeform submission update Airtable",
31
trigger: typeform.onFormResponse({
34
uid: "<your-form-id>",
37
run: async (payload, io, ctx) => {
39
const table = io.airtable
40
.base("<your-base-id>")
41
.table<Submission>("<your-table-name>");
43
if (payload.form_response.answers[0].type !== "text") {
44
throw new Error("The first answer is not a name");
46
const name = payload.form_response.answers[0].text;
48
if (payload.form_response.answers[1].type !== "email") {
49
throw new Error("The second answer is not an email");
51
const email = payload.form_response.answers[1].email;
53
if (payload.form_response.answers[2].type !== "choice") {
54
throw new Error("The third answer is not a choice");
56
const emailContactEnabled =
57
payload.form_response.answers[2].choice.label === "Yes";
60
const newRecords = await table.createRecords("create records", [
71
await io.logger.info("A new form submission was created.", {