Typeform Inbound Example

The following example is a Typeform inbound configuration.

{
  "$version": "2",
  "api": {
    "auth": "oauth2",
    "base_url": "https://api.typeform.com",
    "pagination": {
      "style": {
        "type": "page",
        "page_number": {
          "param": "page",
          "value": 1
        },
        "page_size": {
          "param": "page_size",
          "value": 200
        }
      },
      "parser": {
        "total_pages": {
          "!jq": ".page_count"
        }
      }
    }
  },
  "auth": {
    "typeform_oauth2": {
      "type": "oauth2",
      "configuration": {
        "authorization_base_url": "https://api.typeform.com/oauth/authorize",
        "client_id": "",
        "client_secret": "",
        "scopes": [
          "offline",
          "accounts:read",
          "workspaces:read",
          "forms:read",
          "responses:read",
          "webhooks:read",
          "webhooks:write"
        ],
        "refresh_url": "https://api.typeform.com/oauth/token",
        "token_url": "https://api.typeform.com/oauth/token"
      }
    }
  },
  "data_intake": [
    {
      "name": "form_webhook",
      "type": "webhook",
      "scope": "workflow",
      "create": {
        "!http": {
          "body": {
            "enabled": true,
            "url": "${webhook.url}"
          },
          "method": "PUT",
          "path": "forms/${custom_data.form.value}/webhooks/${webhook.id}"
        }
      },
      "delete": {
        "!http": {
          "method": "DELETE",
          "path": "forms/${custom_data.form.value}/webhooks/${webhook.id}"
        }
      }
    }
  ],
  "workflows": [
    {
      "name": "typeform",
      "label": "Typeform",
      "type": "generic",
      "data_intake": "form_webhook",
      "auth": "typeform_oauth2",
      "resource_type": {
        "singular": "form",
        "plural": "forms"
      },
      "setup": {
        "connect": {
          "label": "Connect",
          "describe_connection": {
            "!pipe": [
              {
                "!http": {
                  "method": "GET",
                  "path": "/me"
                }
              },
              {
                "!jq": ".body | {account_id: .email, description: [.alias, .email] | join(\" - \")}"
              }
            ]
          }
        },
        "select": {
          "label": "Select Form",
          "description": "Select a form from the list.",
          "describe_selection": {
            "resource_id": {
              "!jq": "${custom_data.form.value}"
            },
            "display": {
              "!jq": "${custom_data.form.display}"
            }
          },
          "form_fields": [
            {
              "label": "Choose Your Form",
              "type": "dropdown",
              "id": "form",
              "placeholder": "Select Form",
              "options": {
                "!pipe": [
                  {
                    "!http": {
                      "method": "GET",
                      "path": "/forms",
                      "pagination": true
                    }
                  },
                  {
                    "!jq": "[.body.items[] | {display: .title, value: .id}]"
                  }
                ]
              }
            }
          ]
        },
        "map": {
          "label": "Mapping",
          "describe_source": {
            "label": "Typeform",
            "options": {
              "!pipe": [
                {
                  "!http": {
                    "method": "GET",
                    "path": "/forms/${custom_data.form.value}"
                  }
                },
                {
                  "!jq": ".body | [(.hidden[]? | {id: ., title: ., type: \"hidden\"}), (.. | if .type? != null and .title != null and ([\"group\", \"form\", \"quiz\"] as $type | select( .type as $t | all( $type[]; . != $t))) then . else empty end | { id, title, type })]"
                }
              ]
            }
          },
          "describe_target": {
            "label": "ActiveCampaign",
            "options": {
              "!resource": "ActiveCampaignContact.fields"
            }
          }
        }
      },
      "data_pipeline": {
        "source": {
          "!jq": "([.body.form_response | .answers[] | { key: .field.id, value: (.text // .email // .date // .boolean // .url // .number // .phone_number // .file_url // .payment.amount // .choices.labels // .choice.label // .choice.other ) }] | from_entries) + (.form_response.hidden // {} | with_entries( .key |= .))"
        },
        "target": {
          "!resource": "ActiveCampaignContact"
        }
      }
    }
  ]
}