# Instinct

讓 Instinct 使用 Felo Data API 查詢到的資料。Agent 繼續使用內建模型，Felo 為任務提供搜尋結果。

讓 Instinct 使用 Felo Data API 查詢到的資料。Agent 繼續使用內建模型，Felo 為任務提供搜尋結果。

## 開始前準備

先建立 API key 並確認帳戶有可用額度。本文以 Tavily 搜尋介面為例；其他 Data API 的參數和價格以各自文件為準。

- [API Keys](https://openapi.felo.ai/console/api-keys)
- [Data APIs](https://openapi.felo.ai/zh-TW/apis)
- [Tavily](https://openapi.felo.ai/zh-TW/apis/tavily)

## 在應用程式中設定

**Google Sheets → Extensions → Apps Script → Google Docs → Instinct Google Workspace connection**

## 將查詢設為 Agent 工具

透過 Google Workspace 連接：Apps Script 呼叫 Felo Data API，將結果寫入試算表與 Google 文件，再由 Agent 讀取。不需要 Agent 提供自訂 API 設定。

[felo-data-sheets.gs](https://openapi.felo.ai/docs-assets/integrations/felo-data-sheets.gs)

1. 新增 Google 試算表，開啟「擴充功能 → Apps Script」，貼上下載的指令碼，儲存後執行 setupFeloDataSheet 並授權。
2. 在 Queries!A2 填搜尋詞。在「專案設定 → 指令碼屬性」新增 FELO_API_KEY；不要將 key 寫入儲存格或 Agent 對話。
3. 執行 refreshFeloData。Results 儲存標題、網址、摘要；Config!B1 是輸出 Google 文件連結。再次執行會更新同一份文件。
4. 在 Agent 連接相同 Google 帳號，確認文件讀取權限，提供文件連結，請它讀取內容並引用來源網址。

```text
setupFeloDataSheet()
refreshFeloData()
```

## Data API 請求範例

| Field | Value |
| --- | --- |
| Method | `POST` |
| URL | `https://openapi.felo.ai/v1/beta/tavily/search` |
| Authorization | `Bearer YOUR_FELO_API_KEY` |
| OpenAPI credential | `X-API-Key: YOUR_FELO_API_KEY` |
| Content-Type | `application/json` |
| query | `Felo API Platform documentation` |
| max_results | `3` |
| Output | `results[].title`, `results[].url`, `results[].content` |

```json
{
  "query": "Felo API Platform documentation",
  "max_results": 3
}
```

```bash
export FELO_API_KEY='YOUR_FELO_API_KEY'
curl 'https://openapi.felo.ai/v1/beta/tavily/search' \
  -H "Authorization: Bearer $FELO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "query": "Felo API Platform documentation",
  "max_results": 3
}'
```

## 驗證連接結果

執行搜尋並檢查 results 陣列及 title、url、content 欄位。請 Agent 根據結果摘要並引用網址。空陣列也是有效結果，不代表失敗；到控制台確認本次 Felo API 用量。

## 疑難排解

401：檢查 key 與 Authorization；402：檢查餘額；400：檢查 JSON 與 query；429 或 5xx：退避重試。保留 request_id 供客服查核。Workspace 請檢查指令碼授權與文件權限；電腦工具請確認實際執行環境的 key。

## 更多 Felo 文件

- [Data API](https://openapi.felo.ai/zh-TW/docs/guides/data-api.md)
- [API Reference](https://openapi.felo.ai/zh-TW/docs/data-api)
- [Authentication](https://openapi.felo.ai/zh-TW/docs/authentication.md)
- [Apps & Agents](https://openapi.felo.ai/zh-TW/apps)

## 應用程式官方資料

- [Instinct](https://instinct.com/privacy-policy)

- [Google Apps Script: UrlFetchApp](https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app)
- [Google Apps Script: PropertiesService](https://developers.google.com/apps-script/reference/properties/properties-service)
