# Build a smart contact form and support widget

_Category: Widget and embeds_

Build a contact form that answers questions before they reach your inbox. As customers describe their problem, matching articles appear under the field, and the widget on your website answers first and hands over to your team only when it has to. This tutorial puts the pieces together in about 30 minutes, without code, and ends with an optional step for developers who want the same suggestions in their website's own contact form.

**Who can do this:** Owners and Admins · **Plans:** All plans. AI answers in the widget need Catalyst, or the AI add-on on Bootstrap and Growth.

## What you'll build

- **A smart contact page** on your help center. Customers pick a topic and describe their problem, and the three best-matching articles appear as they type.
- **A support widget** on your website. Visitors search or ask a question, read the answer without leaving the page, and message your team from the widget when they're still stuck.
- **A contact form that asks the right questions.** The widget's form collects what your team needs, such as a name and a topic, and attaches the page and article the visitor wrote from.
- **Optional, with a developer:** article suggestions and an "Ask our assistant" button in the contact form on your own website.

Before you start, publish the articles that answer your most common questions. Suggestions and AI answers come only from published articles, so the better they cover what customers ask, the fewer messages you get. Have your support inbox's address ready too.

## Step 1: Switch on your smart contact page

Your help center's contact page suggests articles out of the box. It stays hidden until it knows where to send messages.

1. In the left menu, click **Template editor**. Open **Pages** and pick **Contact** in the page menu.
2. In the **Main** region, click **Contact form** to edit it.
3. Under **Recipient email**, enter your support inbox's address.

![Screen recording. In Pages, switch to the Contact page. Click Contact form to edit it. Add a Recipient email to switch the contact page on.](https://helpcenter-io.s3.amazonaws.com/uploads/self/5VyA3WFooRCfoRKHdJ69G713z75QqMSbqnSWhfHX.gif)
A recipient switches the contact page on.

1. Under **Form fields**, shape the form. Two changes make the biggest difference:
    - Add a **Dropdown** named "What is it about?" with your main topics, such as orders, billing and your account. Use the arrows to move it to the top, so customers name the topic before they describe the problem.
    - Keep one **Multi-line text** field for the question, and keep it the first field of that type. Suggestions appear under the first Multi-line text field.
2. Check that **Suggest articles while typing** is on. It is by default.
3. Optional: in **Suggestions heading**, write the line above the suggestions, such as "These answers might already help". Left empty, it uses the wording from **Localization**.
4. Write a **Success message** that says when you usually reply, then click **Publish**.

Once you publish, your contact page is live at `/contacts` on your help center, with contact links in your header and footer. Every other option, including a confirmation email to the customer, is in [Set up your contact page and form](https://self.helpcenter.io/content/contact-form).

## Step 2: Try it as a customer

1. Open `/contacts` on your help center in a private browser window.
2. Describe a problem the way a customer would, in the question field.

After a few words, the three articles that match best appear under the field. Each opens in a new tab, so the customer's message stays where it was. Under an article they opened, customers can click **Yes, this answered it**, and the page tells them they can close it.

![Screen recording. Readers pick a Topic and describe their problem. Matching articles appear as they type. One click opens the answer in a new tab, before they send anything. If it helped, they say so, and there is nothing left to send.](https://helpcenter-io.s3.amazonaws.com/uploads/self/2agGG9TzcbQfOIsRkwTDIGtTlB7POaITFoX9LmHK.gif)
Matching articles appear while the customer describes the problem.

If the suggestions miss, check the words you typed against your article titles. Suggestions work best when titles use the words your customers use.

## Step 3: Add the support widget to your website

The widget puts your help center one click away on every page of your website. Visitors search, read articles and ask AI without leaving the page, and its contact form sends to the same Recipient email you set in step 1.

1. In the left menu, click **Embeddables**.
2. On the **Widget** tab, find **Installation** and click **Copy**.
3. Paste the snippet into your website's HTML, right before the closing `</body>` tag, on every page where the widget should appear. On WordPress, the free plugin adds it for you.
4. In **Settings**, add your website under **Embedding origins** and click **Save changes**. The widget loads only on websites on that list.

![Screen recording. In the menu on the left, click Embeddables. Under Installation, click Copy. Paste it just before the closing body tag on every page of your site. Building with a coding agent? Click Copy prompt and paste it into the agent.](https://helpcenter-io.s3.amazonaws.com/uploads/self/DHMqvTs6YAo2n8GjGmSeBQAJYMvZDVIxKdNFH5sy.gif)
Copy the snippet and paste it into your website.

Then make it yours on the same tab: set your brand colors and launcher icon under **Appearance**, and a greeting under **Content**. To let the widget answer questions in its own words, written from your articles, switch on **AI Answers** in **Settings**. The details are in [Add the widget to your website](https://self.helpcenter.io/content/install-the-widget), [Match the widget to your brand](https://self.helpcenter.io/content/widget-appearance) and [Turn on AI Answers](https://self.helpcenter.io/content/ai-answers).

From now on, visitors who don't find an answer see **Still stuck? Message our team →** under an AI answer and at the end of every article, and **Contact our team** when a search finds nothing.

## Step 4: Make the widget's contact form ask the right questions

The widget's standard form asks for an email and a message. Make it ask for what your team needs to answer on the first reply.

1. In **Embeddables**, open the **Contact form** tab and click **Customize form**. The editor opens with a **Live preview, as visitors see it** on the right.
2. Under **Fields**, click **Name** and **Topic**. Topic is a dropdown: click it to change its choices to your own topics.
3. For anything else, such as an order number, click **Another field** and pick a type.
4. Under **Attached context**, switch on **Last search or AI question**. Your team then sees what the visitor already tried, so nobody asks twice. The page and the article they wrote from are attached already.
5. Click **Save and use this form**.

![Screen recording. On Embeddables, open the Contact form tab and click Customize form. Add ready-made fields, such as Name and Topic. Under Attached context, switch on Last search or AI question. Click Save and use this form. Saved: Message our team in the widget now asks for them.](https://helpcenter-io.s3.amazonaws.com/uploads/self/MJUOQvDoiFMdUifEUk1904pCVoXkfO8SCM5VgByw.gif)
Add the fields your team needs, and attach what the visitor tried.

Messages still go to your Recipient email. Under **Email** you can send them to up to 3 other addresses instead, and under **Webhook to your ticketing system** you can turn each one into a ticket in your help desk. See [Customize the widget contact form](https://self.helpcenter.io/content/customize-widget-contact-form).

### Fill in what you already know

If visitors are signed in to your website or app, don't make them type their name or customer number. Add a field of the type **Hidden, set by your website**, such as `customer_number`, and have a developer set it from your page:

```
window.hcWidget.setContactFields({
  name: 'Ada Lovelace',
  customer_number: '1001'
});
```

A visible field gets the value as a starting point the visitor can change. A hidden one arrives with the message, marked as set by your website. The editor's **Fill it from your website** section shows the code for your own fields. See [Widget JavaScript API](https://developers.helpcenter.io/content/widget-javascript-api) on the developer portal.

## Step 5 (optional, with a developer): Suggest answers in your website's own contact form

Many websites have a contact form of their own, with fields a help desk depends on. You can keep it and add two things: answer suggestions under its message field, and a button that opens the widget so visitors can ask your assistant instead.

![Screen recording. A visitor describes their problem on your own contact form. Your form shows matching help articles as they type. Ask our assistant opens the widget, for an AI answer or a message to your team.](https://helpcenter-io.s3.amazonaws.com/uploads/self/4F54kRLgroFUa9JGODaTNwhW0AcHbbGK9sZqCLoD.gif)
Your own form, with answers from your help center under the message field.

### Before you start

- Your help center is public and published. Your website asks it for articles without signing in.
- The website with your form is on your **Embedding origins** list, from step 3. Requests from any other website are refused.
- The widget snippet from step 3 is on the page, for the "Ask our assistant" button.
- You have your widget ID: the `app_id` in your snippet.

### Add the suggestions

As the visitor types, your page searches your help center and lists the top three matches under the field. This example works with a form whose message box has the id `message`. Replace `YOUR_WIDGET_ID` with your widget ID, and set `lang` to the language of the page, such as `de` on your German site.

```
<textarea id="message" name="message" required></textarea>
<div id="suggestions" hidden>
  <p>These answers might already help</p>
  <ul></ul>
</div>
<button type="button" onclick="window.hcWidget && window.hcWidget.show()">
  Or ask our assistant
</button>

<script>
(function () {
  var WIDGET_ID = 'YOUR_WIDGET_ID';
  var lang = 'en';
  var field = document.getElementById('message');
  var box = document.getElementById('suggestions');
  var list = box.querySelector('ul');
  var timer, last = '', seq = 0;

  function show(results) {
    list.textContent = '';
    results.slice(0, 3).forEach(function (article) {
      var item = document.createElement('li');
      var link = document.createElement('a');
      link.href = article.url;
      link.target = '_blank';
      link.rel = 'noopener';
      link.textContent = article.title[lang];
      var excerpt = document.createElement('p');
      excerpt.textContent = article.excerpt[lang];
      item.appendChild(link);
      item.appendChild(excerpt);
      list.appendChild(item);
    });
    box.hidden = list.children.length === 0;
  }

  function search() {
    var q = field.value.trim();
    if (q.length < 3) { box.hidden = true; last = ''; return; }
    if (q === last) { return; }
    last = q;
    var mine = ++seq;
    fetch('https://embed.helpcenter.io/hcembed/v1/' + WIDGET_ID + '/search?lang=' + lang
        + '&q=' + encodeURIComponent(q.slice(0, 200)), { credentials: 'omit' })
      .then(function (response) { return response.ok ? response.json() : { results: [] }; })
      .then(function (data) { if (mine === seq) { show(data.results || []); } })
      .catch(function () { if (mine === seq) { box.hidden = true; } });
  }

  field.addEventListener('input', function () {
    clearTimeout(timer);
    timer = setTimeout(search, 300);
  });
})();
</script>
```

A few things the example takes care of, and yours should too:

- It waits until the visitor pauses (300 milliseconds) and has typed at least 3 characters, so it doesn't search on every keystroke.
- It sets titles and excerpts with `textContent`, never as HTML, so nothing in an article can run as code on your page.
- It ignores an answer that arrives after a newer one, so a slow request never replaces fresher suggestions.
- Articles open in a new tab, so the visitor's half-written message stays where it was.

Each result has a `title` and an `excerpt` per language, and a `url` to the article in the language you searched. `lang` must be one of your help center's languages. Without it, or with any other value, the search runs in your default language.

### Count it in your statistics

The **Contact form** card on the **Statistics** page shows how many visitors found their answer in the suggestions instead of sending a message. Your own form can report to it as well. Add these two lines to the page, with your widget ID:

```
<script>window.hc=window.hc||{q:[],track:function(){window.hc.q.push(arguments)}};</script>
<script async src="https://embed.helpcenter.io/js/hc-track.js" data-hc-widget="YOUR_WIDGET_ID"></script>
```

Then report what happens on the form, for example:

```
hc.track('contact_form', 'view');
hc.track('contact_form', 'suggestions_shown', { query: q, articleIds: [11, 12, 13] });
hc.track('contact_form', 'suggestion_open', { articleId: 11, rank: 1, query: q });
hc.track('contact_form', 'submit', { query: q, articleIds: [11, 12, 13] });
```

The script sends only what you report, nothing else from the page. Every event, and how to add a "This answered my question" button, is in [Track your own contact form](https://developers.helpcenter.io/content/widget-custom-contact#track-your-own-contact-form) on the developer portal. If your website sends a Content Security Policy, allow `embed.helpcenter.io`: see [Content Security Policy](https://developers.helpcenter.io/content/content-security-policy).

## See what it saves you

After a few days, open **Statistics**. The **Contact form** card shows how many visitors read a suggested article instead of sending a message, and **Visitor journeys** shows how many self-served and how many contacted support. Searches with no results point to the articles to write next: each one you add makes the suggestions and the widget better. On a plan you build yourself, these cards need Insights. See [Read your help center statistics](https://self.helpcenter.io/content/statistics).

## Troubleshooting

**The contact page shows "not found", or the widget shows no way to contact you.** The published contact form has no **Recipient email**. Add one in the template editor and click **Publish**. See [The contact form or "Ask us" button is missing](https://self.helpcenter.io/content/contact-form-missing).

**No suggestions appear on the contact page.** Check that **Suggest articles while typing** is on, and that the question field is the form's first Multi-line text field. Suggestions come only from published articles that readers may see.

**Your own form gets no suggestions, and the browser console shows a refused request.** Add your website to **Embedding origins**, and check that your help center is public and published. An address that isn't on the list gets no answer.

**Suggestions on your own form come back in the wrong language.** Set `lang` to a language your help center has, such as `de`.

**The "Ask our assistant" button does nothing.** The widget snippet isn't on that page, or the page isn't on your **Embedding origins** list.

## Related articles

- [Set up your contact page and form](https://self.helpcenter.io/content/contact-form)
- [Customize the widget contact form](https://self.helpcenter.io/content/customize-widget-contact-form)
- [Let visitors message your team from the widget](https://self.helpcenter.io/content/widget-contact-form)
- [Add the widget to your website](https://self.helpcenter.io/content/install-the-widget)
- [Choose which websites can show the widget](https://self.helpcenter.io/content/embedding-origins)
- [Reduce support tickets with self-service](https://self.helpcenter.io/content/reduce-support-tickets)
