untitled-6888
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
A REST API endpoint that receives Typeform webhook submissions and forwards them as events to PostHog.
- Set the
POSTHOG_API_KEYenvironment variable in your Val Town settings with your PostHog API key.
Accepts Typeform webhook payloads and sends a typeform_completed event to PostHog.
Request Body:
{ "form_response": { "form_id": "form_123", "token": "response_456", "submitted_at": "2024-01-01T12:00:00Z", "landed_at": "2024-01-01T11:55:00Z", "hidden": { "user_id": "user_789", "source": "email_campaign" } } }
Response:
200 OK: Event successfully sent to PostHog500 Internal Server Error: Missing API key or PostHog API error
Health check endpoint that returns API information.
The endpoint sends events to PostHog with the following structure:
- Event Name:
typeform_completed - Distinct ID: Uses
hidden.user_id, falls back tolanded_at, then'anonymous' - Properties: Includes all hidden fields plus:
form_id: Typeform form identifierresponse_id: Typeform response tokensubmitted_at: Submission timestamp
In your Typeform settings:
- Go to Connect → Webhooks
- Add webhook URL:
https://your-val-url.web.val.run/typeform-submit - Select "Form submitted" trigger
- Configure any hidden fields you want to pass through to PostHog
POSTHOG_API_KEY: Your PostHog project API key (required)