# Ask your boards

> Find the boards about a topic and answer a question from them, for an assistant or Slack bot.

Source: https://mockflow.com/developers/examples/api/ask-your-boards

Teams make decisions on boards: launch plans, retros, research. Weeks later someone asks "what did we decide about pricing for the Q3 launch?" and nobody remembers which board it was on. This example finds the right board and answers from it, the core of an internal assistant or a Slack bot.

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

## What it does

Two ways to answer, from the same search:

- **Mida answers:** Mida, MockFlow's AI assistant, answers from the best matching board and names the items it used.
- **Your own model answers:** the matching boards are printed as Markdown, ready to put in your AI model's prompt or a search index. This needs only read access and works on every plan.

## How it works

1. [Search](/developers/reference/search/search) board titles with `GET /search?type=board&q=Q3 launch`.
2. For Mida's answer, [ask about the board](/developers/reference/ai/ai-ask) with `POST /boards/{boardId}/ai/ask` and the question. The answer is Markdown with `sources`.
3. For your own model, [read each board as text](/developers/reference/boards/get-board-outline) with `GET /boards/{boardId}/outline` and `Accept: text/markdown`: its sections, the items in reading order and the connections between them.

## Run the example

Create an API key in the [developer console](/developers/console/) with the scopes `user:read` and `boards:read`, adding `ai:generate` for Mida's answers, then:

```bash
cp .env.example .env        # paste your key into .env
node ask.js "Q3 launch" "What did we decide about pricing?"
node ask.js "Q3 launch" "What did we decide about pricing?" --context
```

## The key code

```javascript
const found = await mf.get(`/search?type=board&limit=3&q=${encodeURIComponent(topic)}`);
const best = found.data[0];

// Mida answers, with sources
const res = await mf.post(`/boards/${best.boardId}/ai/ask`, { question });

// Or: the board as Markdown for your own model
const outline = await mf.get(`/boards/${best.boardId}/outline`, { accept: 'text/markdown' });
```

## Adapt it

- **Slack bot:** run the same steps from a slash command and reply with the answer and the board's link.
- **Weekly digest:** read the outlines of boards changed this week and have your model summarise them for a newsletter.
- **Search index:** index every board's outline so your intranet search finds what is on boards.

To let other people connect their own boards to your assistant, see [Read-only connector for an AI assistant](/developers/examples/oauth/assistant-connector).

## What you need

An API key with `user:read` and `boards:read` for search and outlines, on every plan. Mida's answers add `ai:generate`, need Plus or Max, and use AI credits.
