Highlight to Ask AI 🚧
🚧 [Experimental] Highlight anything on the page and ask your Algolia Ask AI about it.
Leverage Algolia Ask AI's context to answer questions about any highlighted text on your page.
- Documentation websites
- Interactive blog posts & tutorials
Try it
Select any text in this block to see a small tooltip. Click Ask AI? to expand the panel. We’ll wire streaming later.
The tooltip respects excluded elements like pre andcode, and it uses smart placement to avoid viewport edges.
Tip: Try selecting a sentence across multiple lines.
npx shadcn@latest add @algolia/highlight-to-askai
This will add the Highlight to AskAI experience to your project under components/highlight-to-askai. Use it like this:
import HighlightToAskAi from "@/components/highlight-to-askai";
<HighlightToAskAi
applicationId="betaHAXPMHIMMC"
apiKey="8b00405cba281a7d800ccec393e9af24"
indexName="algolia_podcast_sample_dataset"
assistantId="Y89iGlsnihaU"
excludeElements={["pre", "code"]}
askButtonLabel="Ask AI?"
onAsk={(payload) => {
console.log(payload);
}}
>
<article>
<h1>My Article</h1>
<p>This is my article content.</p>
</article>
</HighlightToAskAi>
Prerequisites for using the HighlightToAskAi component:
applicationId: The Algolia application ID
apiKey: The Algolia API key
indexName: The Algolia index name
assistantId: The Ask AI assistant ID
Optional props:
excludeElements: An array of HTML elements to exclude from the highlighted text.
askButtonLabel: The label for the ask button.
onAsk: A callback function that will be called when the ask button is clicked.
- Change the styling to match your brand
- Open in v0 for more customization