# Read-only connector for an AI assistant

> Let users connect MockFlow to your AI assistant with read access only.

Source: https://mockflow.com/developers/examples/oauth/assistant-connector

An AI assistant product wants to answer from its users' MockFlow boards: "summarise the onboarding research board", "what is still open on the launch plan?". People will only connect it if they can trust it. This example asks for read access only, so MockFlow's consent screen tells people plainly that the assistant can read their boards and cannot change them.

[**Download the code**](/developers/assets/examples/mockflow-assistant-connector.zip) (Node.js 18 or later, no packages)

## What it does

- Asks for the scopes `user:read` and `boards:read`, and nothing more.
- Lists the user's recently updated boards, and searches their boards by title.
- For a chosen board, shows exactly what the assistant reads: the board's outline as Markdown, to put in the model's prompt with the user's question.
- Treats a `401` from the API as the user having disconnected the app in MockFlow.

## How it works

1. The user connects through the [OAuth flow](/developers/concepts/oauth-apps) with `scope=user:read boards:read`. Asking for the least a feature needs is the best way to be trusted; see [Scopes](/developers/concepts/scopes).
2. List [recent boards](/developers/reference/boards/list-recent-boards) with `GET /boards/recent`, or [search](/developers/reference/search/search) with `GET /search?type=board&q=`.
3. Read a board [as text](/developers/reference/boards/get-board-outline) with `GET /boards/{boardId}/outline` and `Accept: text/markdown`, and give it to your model with the question.

## Run the example

Register an app in the **OAuth apps** tab of the [developer console](/developers/console/?tab=oauth) with the redirect URI `http://localhost:3000/oauth/callback` and only the scopes `user:read` and `boards:read`. Then:

```bash
cp .env.example .env        # paste the client ID and secret into .env
node server.js              # open http://localhost:3000
```

## The key code

```javascript
const SCOPES = 'user:read boards:read';   // what the consent screen shows

const token = await accessTokenFor(store, userId, app);
if (!token) return redirect(res, '/connect');
const mf = new MockFlow({ token });

const board = await mf.get(`/boards/${boardId}`);
const outline = await mf.get(`/boards/${board.id}/outline`, { accept: 'text/markdown' });
// put `outline` and the user's question in your model's prompt
```

## Adapt it

- **Chat assistants:** add the outline of the board a user mentions to the conversation.
- **Meeting notes tools:** link a meeting's board and include its decisions in the summary.
- **Enterprise search:** index the outlines of the boards each user can open.

## What you need

An OAuth app with the scopes `user:read` and `boards:read`. Works for users on every plan.
