Adding a Contact Form to Astro is the simplest of any modern framework: paste the embed straight into your .astro file and ship. The Helpdesky Contact Form drops in as one container div and one script tag, handles its own validation, and lands every submission in your Helpdesky inbox where you can reply by email.
This guide is for anonymous visitors. There is no login, no HMAC, no backend wiring. If you need a portal for signed in users instead, see the Ticket Center Setup Guide.
A quick word on why this is a fair trade: the Helpdesky Free plan covers the first 15 conversations every month, you do not stand up SMTP or a custom API route, and the form is a single snippet you commit to your Astro repo. Replies you send from the Helpdesky inbox are emailed back to the visitor automatically.
Set Up Your Helpdesk
Open the Helpdesky dashboard and go to Contact Form in the sidebar. Copy the embed snippet at the top of the page. It already has your Helpdesk ID filled in:
<div id="hdh-contact-form"></div>
<script src="https://helpdesky.io/contact-form.js"
data-helpdesk-id="YOUR_HELPDESK_ID"></script>
While you are there, also enable messaging from the Messages sidebar item if you have not already. The toggle is at the top of the Messages page.
Add the Embed Code
Astro renders to static HTML by default, so the embed snippet works as is. Open the contact page (typically src/pages/contact.astro) and paste the container plus script directly into the template:
---
import Layout from "../layouts/Layout.astro";
---
<Layout title="Contact us">
<main class="mx-auto max-w-2xl py-16">
<h1>Contact us</h1>
<div id="hdh-contact-form"></div>
<script
is:inline
src="https://helpdesky.io/contact-form.js"
data-helpdesk-id="YOUR_HELPDESK_ID"
></script>
</main>
</Layout>
The is:inline directive tells Astro to leave the script tag alone instead of bundling it. That matters because Helpdesky's script reads its config from its own data-* attributes, which Astro's bundler would otherwise strip.
Test It
Run astro dev, open /contact, submit a test message, and confirm it appears in your Helpdesky Messages inbox. If the form fails to render after deploy, open the page source and confirm the script tag is present and unchanged. If data-helpdesk-id is missing, you forgot is:inline.
Next Steps
Route inbound support email into the same helpdesk by following the Email Forwarding Setup Guide. If you start getting bot submissions, layer on bot protection with the Cloudflare Turnstile Setup Guide. When you ship a signed in dashboard, swap the public form for a Ticket Center so users can see their full conversation history.
Have an AI Agent Handle Form Replies
Shipping the form is the easy half; answering the messages is the ongoing part. Under Inbox → AI Agents (beta) you can create an agent that drafts replies from your help center content. Choose its Mode: Review holds every draft for one click approval in the inbox, Autopilot sends on its own within the pacing and guardrails you set.
In Behaviour → Channels, switch on Contact form so conversations from your Astro site reach the agent. Replies go to the visitor by email, exactly like a reply you type in the dashboard.
Agents use your own AI provider key, saved in Settings → AI Settings; nothing runs until one is there. See Set Up Your First AI Agent for the full setup and the guardrails and pacing guide for reply delays, daily caps and hand off rules.
Cool Features
A couple of small things you can turn on once the basic form is live.
- Hide outer border: drop the form into any section without a background or border so it blends straight into your branding. From the Contact Form page, open the Layout section and toggle Hide outer border.
- Cloudflare Turnstile spam protection: if your domain is on Cloudflare, you can protect the form from bots in a few clicks. Open your Cloudflare account, go to Turnstile, add your domain, generate the keys, and paste them into the Helpdesky Contact Form settings. Full walkthrough in the Cloudflare Turnstile Setup Guide.
Allowed Embed Domains: prevent other sites from loading the form with your Helpdesk ID, which is public in your page source. Under Settings → Messages → Allowed Embed Domains, add your production domain and any preview domains you test on; subdomains are included automatically, and an empty list allows every domain. Details in Restrict Embeds to Specific Domains.
Make the form yours: add Custom Fields of type Text, Text Area, Dropdown, Checkbox or Number; they render between Email and Message and can be marked required. Labels, placeholders, the button text and the success text are all editable, so the form can be in whatever language your site is written in. Accent Style paints the button with your Branding colours, Use Branding Background and the colour pickers cover the rest, and the Custom CSS section has a View example snippets library (Brand Colors, Dark Mode / Dark Background, Rounded / Pill Style, Flat / Minimal, Custom Fonts, Full-Width Bold Button, Compact Form). The Contact Form Setup Guide covers each setting.