Skip to content

Conversation

@ethanpalm
Copy link
Collaborator

@ethanpalm ethanpalm commented Nov 5, 2025

Documentation changes

Adds a guide on embedding the assistant as a widget in a React app.

Closes https://linear.app/mintlify/issue/DOC-79/create-a-guide-explaining-how-to-integrate-the-assistant-api-into-a


For Reviewers

When reviewing documentation PRs, please consider:

✅ Technical accuracy

  • Code examples work as written
  • Commands and configurations are correct
  • Links resolve to the right destinations
  • Prerequisites and requirements are accurate

✅ Clarity and completeness

  • Instructions are clear and easy to follow
  • Steps are in logical order
  • Nothing important is missing
  • Examples help illustrate the concepts

✅ User experience

  • A new user could follow these docs successfully
  • Common gotchas or edge cases are addressed
  • Error messages or troubleshooting guidance is helpful

Note

Adds a new guide for embedding the assistant as an in-app React widget and updates navigation to include it.

  • Guides:
    • New tutorial guides/assistant-embed.mdx:
      • Build a reusable React AssistantWidget using @ai-sdk/react useChat with streaming, Markdown rendering, and suggestions parsing.
      • Setup: install ai, @ai-sdk/react, react-markdown; configure VITE_MINTLIFY_TOKEN; usage example with domain and docsURL props.
      • Customizations: color theming, widget positioning, source citations, thread ID persistence via x-thread-id, keyboard shortcuts.
      • Troubleshooting: auth errors, no responses, network debugging.
  • Navigation:
    • Add guides/assistant-embed to docs.json under Guides > AI; minor reordering of guides/geo within the group.

Written by Cursor Bugbot for commit 92f4515. This will update automatically on new commits. Configure here.

## What you will build

A reusable React component that embeds the [assistant](/ai/assistant) directly in your application. The component provides:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opinion: I would've appreciated some sort of gif or image to showcase what the completed product will look like


Users can use the widget to get help with your product without leaving your application.

<PreviewButton href="https://github.com/mintlify/assistant-embed-example">Clone the repository to start working with a complete example locally.</PreviewButton>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, when I went through the readme instruction on the github repo, none of the tailwind styles showed up. Luckily it, only took one prompt on Cursor to fix them for me. Here's that conversation thread:

cursor_troubleshooting_tailwind_css_sty.md

Copy link

@paaatrrrick paaatrrrick Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: for calling AssistantWidget in App.tsx, I'm more used to domain and docsURL being defined first as global variables rather than being passed directly to the component.

<Steps>
<Step title="Install dependencies">

Install the AI SDK for React and a Markdown renderer:
Copy link

@paaatrrrick paaatrrrick Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: While I did figure it out, I found this to be a point of some confusion. Since you don't first give a command to create a vite app, I assume your tutorial expects me to follow the github repo you linked above. However, if I had cloned the github repo, then npm i should've taken care of this. This left me a bit confused on the expected way to follow your tutorial.

import { useState } from 'react';
import ReactMarkdown from 'react-markdown';

const parseSuggestionLinks = (markdown, docsURL) => {
Copy link

@paaatrrrick paaatrrrick Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leading with two helper functions that have some more complex code (regex) made me immediately zone out while reading this file. Could you move these two to a separate file called utils.ts and then import them.


<div className="flex-1 overflow-y-auto p-4 space-y-4">
{messages.map((message) => (
<div key={message.id} className={`flex ${message.role === 'user' ? 'justify-end' : 'justify-start'}`}>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we move each message to seperate component? This is just a best practice in react and will make the file more readable.

) : (
<div className="overflow-x-hidden">
<ReactMarkdown
className="prose prose-sm max-w-none text-sm break-words"
Copy link

@paaatrrrick paaatrrrick Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Text in the ReactMarkdown component is center aligned. Could we switch this to be left aligned?

Screenshot 2025-11-10 at 5 26 44 PM

Import and render the component in your application.

Pass the required props.

Copy link

@paaatrrrick paaatrrrick Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me, the formatting of this text felt dense, making it hard to read. Any way to break it up?

Screenshot 2025-11-10 at 5 28 46 PM


The [example repository](https://github.com/mintlify/assistant-embed-example) includes several of these customizations already implemented, including color customization, positioning options, and source citations.

### Add color customization
Copy link

@paaatrrrick paaatrrrick Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sections "Add color customization" and "Add widget positioning options" seem unnecessary to me. I'd expect that if a reader wanted to use the code this tutorial gave them, that they'd be opinionated enough to probably switch a lot of the styles themselves, which is a pretty trivial thing to do.

On this point, I'd also remove position and buttonColor as inputs to the AssistantWidget.

## Troubleshooting

<AccordionGroup>
<Accordion title="Widget not appearing">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd remove this section as I think it is very unlikely they'd encounter this issue and then consult these docs for a solution to it (these are pretty simple fixes).

<div key={message.id} className={`flex ${message.role === 'user' ? 'justify-end' : 'justify-start'}`}>
<div className={`max-w-[85%] rounded-lg px-4 py-2 break-words ${message.role === 'user' ? 'bg-blue-600 text-white' : 'bg-gray-100 text-gray-900'}`}>
{message.role === 'user' ? (
<div className="text-sm whitespace-pre-wrap break-words">{message.content}</div>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

break-words gives me the following warning in my IDE. Could we switch its usage to wrap-break-word

Screenshot 2025-11-10 at 5 43 10 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants