| title | Typeform |
|---|
npm install @trigger.dev/typeform@latestpnpm install @trigger.dev/typeform@latestyarn add @trigger.dev/typeform@latestTypeform supports Personal Access Tokens, to create yours read the Typeform Personal Access Token guide.
import { Typeform } from "@trigger.dev/typeform";
//create Typeform client using a person access token
const typeform = new Typeform({
id: "typeform-1",
token: process.env.TYPEFORM_PAT!,
});The Typeform Integration allows you to trigger a job run when a new form response is submitted using the onFormResponse trigger:
import { client } from "@/trigger";
import { Typeform } from "@trigger.dev/typeform";
import { Job } from "@trigger.dev/sdk";
export const typeform = new Typeform({
id: "typeform-1",
token: process.env.TYPEFORM_API_KEY!,
});
client.defineJob({
id: "do-something-on-new-responses",
name: "Send a message to slack on new responses",
version: "0.1.1",
trigger: typeform.onFormResponse({
uid: "<form id>",
tag: "your-tag-here",
}),
run: async (payload, io, ctx) => {},
});To find your Form ID, visit your Typeform dashboard and find the form you'd like to use. Click on the "Share" navigation link and you'll find your Form ID in the share URL:
The tag parameter is a unique name you want to use for the webhook, and maps 1-to-1 with a single webhook source. Changing the tag will cause another webhook to be registered with Typeform. You can make use of the same tag value in multiple job triggers.
| Function Name | Description |
|---|---|
listForms |
Retrieve a list of Forms. |
getForm |
Get a single form by uid. |
listResponses |
Pagintated list of responses by form. |
getAllResponses |
Will collect all the responses on a form by making multiple requests to listResponses |
import { Typeform } from "@trigger.dev/typeform";
//create Typeform client using a person access token
const typeform = new Typeform({
id: "typeform-1",
token: process.env.TYPEFORM_PAT!,
});
client.defineJob({
id: "typeform-tasks",
name: "Typeform Tasks",
version: "0.1.0",
integrations: { typeform },
trigger: eventTrigger({
name: "typeform.tasks",
}),
run: async (payload, io, ctx) => {
const forms = await io.typeform.listForms("list-forms");
const form = await io.typeform.getForm("get-form", {
uid: payload.formId,
});
const listResponses = await io.typeform.listResponses("list-responses", {
uid: payload.formId,
pageSize: 50,
});
const allResponses = await io.typeform.getAllResponses("get-all-responses", {
uid: payload.formId,
});
},
});You can use the underlying client to do anything @typeform/api-client supports:
import { Typeform } from "@trigger.dev/typeform";
//create Typeform client using a person access token
const typeform = new Typeform({
id: "typeform-1",
token: process.env.TYPEFORM_PAT!,
});
client.defineJob({
id: "typeform-client",
name: "Typeform Client",
version: "0.1.0",
integrations: { typeform },
trigger: eventTrigger({
name: "typeform.client",
}),
run: async (payload, io, ctx) => {
const form = await io.typeform.runTask(
"create-form",
async (client) => {
return client.forms.create({
data: {
title: "My Form",
fields: [
{
title: "What is your name?",
type: "short_text",
ref: "name",
},
{
title: "What is your email?",
type: "email",
ref: "email",
},
],
},
});
},
{ name: "Create Form" }
);
},
});