Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ You should now be ready to chat!
We've included some examples of Open Chat Widget installed in web app projects as reference:


- [`examples/vite-express-app`](./examples/vite-express-app): Open Chat Widget installed in a React + Vite frontend with an Express backend.
- [`examples/vite-express-app`](./examples/vite-express-app): Open Chat Widget installed in a React + Vite frontend with an Express backend. Supports attachments and web search.
- [`examples/nextjs-landing-page`](./examples/nextjs-landing-page): Open Chat Widget installed on a Next.js app with API Routes. This is the live landing page too.

## [Roadmap](./ROADMAP.md)
Expand Down
10 changes: 10 additions & 0 deletions UPGRADE_EXAMPLES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Objective
I want to upgrade the examples in our examples repo.

# Tasks
1. Upgrade the version of @openchatwidget/sdk to 0.1.2, the newest version that we put out
2. Then run npm i to upgrade the packages.
3. For basic-react-express-app, can you add web search and gpt-5-mini? Look at how our sdk/sandbox agent does it.
4. Also change the examples/nextjs-landing-page to use gpt-5-mini, but no web search though.
5. Update the examples README's to teach the user how to install, configure environment variables, and run it locally.
6. Update our docs to accurately represent our examples repos. We should have dedicated pages for our examples.
15 changes: 10 additions & 5 deletions docs/example-basic-react-express-app.mdx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
title: "React + Express Example"
description: "Use the Vite and Express example when you want the frontend and agent server split apart."
description: "Run the Vite + Express example with gpt-5-mini and native OpenAI web search."
---

This folder contains a minimal Vite + Express app wired to `OpenChatWidget`.
This example runs Open Chat Widget in a Vite frontend with an Express backend.
The backend uses `gpt-5-mini` and enables OpenAI's native `web_search` tool.

## Key files

Expand All @@ -20,20 +21,24 @@ cd /Users/matt8p/Desktop/openchatwidget/examples/basic-react-express-app
npm install
```

2. Add env vars for the Express agent:
2. Configure environment variables:

```bash
cp .env.example .env
```

```env
OPENAI_API_KEY=your_key_here
```

3. Start both the frontend and backend:

```bash
npm run dev
```

Frontend: `http://localhost:5173`
API: `http://localhost:8787/api/chat`
- Frontend: `http://localhost:5173`
- API: `http://localhost:8787/api/chat`

The landing page mounts `<OpenChatWidget />`, and the widget streams responses from the Express `POST /api/chat` endpoint.

Expand Down
14 changes: 7 additions & 7 deletions docs/example-nextjs-landing-page.mdx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
title: "Next.js Landing Page"
description: "Use the Next.js App Router example that powers the Open Chat Widget landing page."
description: "Use the Next.js App Router example with gpt-5-mini and a serverless chat route."
---

This example wires `@openchatwidget/sdk` into a Next.js App Router project.
The `POST /api/chat` route uses `gpt-5-mini` and does not enable web search.

It includes:

Expand All @@ -17,27 +18,26 @@ It includes:
- `examples/nextjs-landing-page/app/api/chat/route.ts`
- `examples/nextjs-landing-page/src/landing/pages/LandingPage.tsx`

## Getting started
## Run it

Install dependencies:
1. Install dependencies:

```bash
cd /Users/matt8p/Desktop/openchatwidget/examples/nextjs-landing-page
npm install
```

Create a local env file:
2. Configure environment variables:

```bash
cp .env.example .env.local
```

Add your OpenAI API key:

```env
OPENAI_API_KEY=your_key_here
```

Start the dev server:
3. Start the dev server:

```bash
npm run dev
Expand Down
14 changes: 8 additions & 6 deletions docs/examples.mdx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
title: "Examples Overview"
description: "Browse the example repos included with Open Chat Widget and choose the setup closest to your stack."
description: "Browse dedicated docs pages for each Open Chat Widget example repo."
---

We've included some examples of Open Chat Widget installed in web app projects as reference:
Open Chat Widget ships with two example repos. Each one has its own dedicated docs page with install, environment variable setup, and local run instructions.

<Frame>
<img
Expand All @@ -21,10 +21,11 @@ We've included some examples of Open Chat Widget installed in web app projects a
href="/example-nextjs-landing-page"
horizontal
>
Use the same setup as the repo's landing page: a Next.js App Router app with a serverless `POST /api/chat` route and the widget mounted on the page.
Next.js App Router app with the widget mounted in the page and a serverless `POST /api/chat` route using `gpt-5-mini`.
</Card>

- `examples/nextjs-landing-page`: Open Chat Widget installed on a Next.js app with API Routes. This is the live landing page too.
- Repo folder: `examples/nextjs-landing-page`
- Docs page: `/example-nextjs-landing-page`

## React + Express example

Expand All @@ -34,10 +35,11 @@ We've included some examples of Open Chat Widget installed in web app projects a
href="/example-basic-react-express-app"
horizontal
>
Use this example when you want the frontend and agent server separated.
Vite frontend + Express backend with `gpt-5-mini` and native OpenAI `web_search`.
</Card>

- `examples/basic-react-express-app`: Open Chat Widget installed in a React + Vite frontend with an Express backend.
- Repo folder: `examples/basic-react-express-app`
- Docs page: `/example-basic-react-express-app`

## Which example should you start from?

Expand Down
30 changes: 18 additions & 12 deletions examples/basic-react-express-app/README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
# OpenChatWidget Examples
# React + Express Example

This folder contains a minimal Vite + Express app wired to `OpenChatWidget`.
This example runs Open Chat Widget in a Vite frontend with an Express backend.
The backend uses `gpt-5-mini` and enables the native OpenAI `web_search` tool.

## Run it

1. Install dependencies:
## Install

```bash
cd /Users/matt8p/Desktop/openchatwidget/examples/basic-vite-express-app
cd /Users/matt8p/Desktop/openchatwidget/examples/basic-react-express-app
npm install
```

2. Add env vars for the Express agent:
## Configure environment variables

Create a local env file:

```bash
cp .env.example .env
```

3. Start both the frontend and backend:
Set your OpenAI API key in `.env`:

```env
OPENAI_API_KEY=your_key_here
```

## Run locally

```bash
npm run dev
```

Frontend: `http://localhost:5173`
API: `http://localhost:8787/api/chat`
- Frontend: `http://localhost:5173`
- API: `http://localhost:8787/api/chat`

The landing page mounts `<OpenChatWidget />`, and the widget streams responses
from the Express `POST /api/chat` endpoint.
The widget sends chat requests to the Express `POST /api/chat` endpoint and streams responses back to the UI.
Loading
Loading