All components · Category: Forms
Chat FAQ
A chat-looking FAQ that answers from your own list of questions.
Quick-reply chips, typing dots and answers that follow a tree of questions you write. There is no AI: every answer is text you wrote. New messages are announced to screen readers and the chips work with the keyboard.
01
Try it
Props
Generated from the component's manifest and the values above.
index.html
<chat-faq locale="en"></chat-faq>
<script>
const element = document.querySelector("chat-faq");
element.addEventListener("chat-faq:asked", (event) => {
console.log(event.detail);
});
</script>
- Add the site's Taggor script once; the component appears when it loads.
taggor-component.js
const element = document.createElement("chat-faq");
element.setAttribute("locale", "en");
element.addEventListener("chat-faq:asked", (event) => {
console.log(event.detail);
});
document.body.append(element);
- Add the site's Taggor script once; the component appears when it loads.
ChatFaq.tsx
import { useEffect, useRef } from "react";
export function ChatFaq() {
const ref = useRef<HTMLElement>(null);
useEffect(() => {
const element = ref.current;
if (!element) return;
const onAsked = (event: Event) => {
console.log((event as CustomEvent).detail);
};
element.addEventListener("chat-faq:asked", onAsked);
return () => {
element.removeEventListener("chat-faq:asked", onAsked);
};
}, []);
return <chat-faq ref={ref} locale="en" />;
}
- Add the site's Taggor script once; the component appears when it loads.
- React 18 sends every prop of a custom element as a text attribute.
- The event is heard with addEventListener, inside an effect.
ChatFaq.tsx
import { useEffect, useRef } from "react";
export function ChatFaq() {
const ref = useRef<HTMLElement>(null);
useEffect(() => {
const element = ref.current;
if (!element) return;
const onAsked = (event: Event) => {
console.log((event as CustomEvent).detail);
};
element.addEventListener("chat-faq:asked", onAsked);
return () => {
element.removeEventListener("chat-faq:asked", onAsked);
};
}, []);
return <chat-faq ref={ref} locale="en" />;
}
- Add the site's Taggor script once; the component appears when it loads.
- React 19 sets a property when the element already has it, an attribute otherwise.
- The event is heard with addEventListener, inside an effect.
src/ChatFaq.vue
<script setup lang="ts">
function onAsked(event: Event) {
console.log((event as CustomEvent).detail);
}
</script>
<template>
<chat-faq locale="en" @chat-faq:asked="onAsked" />
</template>
vite.config.ts
import vue from "@vitejs/plugin-vue";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [
vue({
template: {
compilerOptions: {
isCustomElement: (tag) => tag === "chat-faq",
},
},
}),
],
});
- Add the site's Taggor script once; the component appears when it loads.
- vite.config.ts tells Vue that this tag is not a Vue component.
src/app/chat-faq.component.ts
import { afterNextRender, Component, CUSTOM_ELEMENTS_SCHEMA, DestroyRef, ElementRef, inject } from "@angular/core";
@Component({
selector: "app-chat-faq",
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<chat-faq locale="en"></chat-faq>
`,
})
export class ChatFaqComponent {
constructor() {
const host = inject<ElementRef<HTMLElement>>(ElementRef);
const element = () => host.nativeElement.querySelector("chat-faq");
const onAsked = (event: Event) => {
console.log((event as CustomEvent).detail);
};
afterNextRender(() => element()?.addEventListener("chat-faq:asked", onAsked));
inject(DestroyRef).onDestroy(() => element()?.removeEventListener("chat-faq:asked", onAsked));
}
}
- Add the site's Taggor script once; the component appears when it loads.
- The component declares CUSTOM_ELEMENTS_SCHEMA.
- The event is heard with addEventListener, inside an effect.
src/TaggorComponent.svelte
<script>
function onAsked(event) {
console.log(event.detail);
}
</script>
<chat-faq locale="en" onchat-faq:asked={onAsked}></chat-faq>
- Add the site's Taggor script once; the component appears when it loads.
How an agent gets a component like this onto a site:
taggor checktaggor publishThe CSS variables the component exposes, set the way a customer's page would.
styles.css
chat-faq {
--cf-radius: 18px;
}02
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| nodes | list | none | The questions: id, label (the chip), answer, and parent (the id it is a follow-up of; empty for the first level). |
| greeting | string | none | Replaces the first message. |
| heading | string | none | Replaces the title of the chat. |
| hideSample | boolean | false | Hides the Sample content mark (use it with your own text). |
| locale | pt-BR | en | en | – |
Prop names and descriptions are the component's own, in English, as its author wrote them.
03
Events
| Event | When it fires |
|---|---|
| asked | The visitor picked a question. |
04
Build one with your agent
Paste this into your agent. It asks you before it signs in, pays or goes further than checking and publishing.
Build me a Taggor component like "Chat FAQ" (chat-faq): A chat-looking FAQ that answers from your own list of questions.
Fetch https://taggor.dev/agent-setup/prompt.md and follow its instructions to set me up for Taggor. Ask me before you sign in, create an account, accept terms, pay for anything or type a secret.
Check it with `taggor check` and publish it with `taggor publish`, and stop there.
Do not promote it to production, attach it to a site, roll back anything or use --yes, --force or --force-drop-invalid unless I ask for exactly that in this conversation.
05
Related components
- FAQ accordion<faq-accordion>
- Search with suggestions<search-suggest>
- Contact hours<contact-hours>