# Get AI Recommendations — Dappier

> Get AI-ranked content recommendations for a Dappier data model (POST /app/v2/search, with data_model_id passed as a query parameter). Returns a structured results array of ranked articles (title, summary, url, score, source, pubdate…

- Key: `dappier-get-ai-recommendations`
- Type: Action (Read-only)
- Version: 0.0.2
- App: Dappier (`dappier`) — https://pipedream.com/apps/dappier.md
- This page (HTML): https://pipedream.com/apps/dappier/actions/get-ai-recommendations
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/dappier/actions/get-ai-recommendations/get-ai-recommendations.mjs

## Description

Get AI-ranked content recommendations for a Dappier data model (POST `/app/v2/search`, with `data_model_id` passed as a query parameter). Returns a structured `results` array of ranked articles (title, summary, url, score, source, pubdate, etc.). Provide a `dataModelId` (prefix `dm_`, e.g. `dm_01hpsxyfm2fwdt2zet9cg6fdxt` - a known real-time web search data model). NOTE `dm_` data-model IDs are distinct from the `am_` AI-model IDs used by **Search Real-Time Data**. There is no listing endpoint in the Dappier API; discover valid data model IDs in the Dappier Marketplace at https://platform.dappier.com/marketplace. Example: `dataModelId=dm_01hpsxyfm2fwdt2zet9cg6fdxt`, `query=top technology stories today` returns the top-ranked matching articles; pass `fields=["title","url","summary"]` to trim each result to just those keys. [See the documentation](https://docs.dappier.com/api-reference/endpoint/ai-recommendations).

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `dataModelId` | `string` | Yes | The Dappier data model ID to query (prefix dm_, e.g. dm_01hpsxyfm2fwdt2zet9cg6fdxt, a known real-time web search data model). This is a data-model ID, distinct from the am_ AI-model IDs used by Search Real-Time Data. Discover valid IDs in the Dappier Marketplace: https://platform.dappier.com/marketplace (the Dappier API exposes no listing endpoint). Sent as the data_model_id query parameter. |
| `query` | `string` | Yes | The natural-language query or context used to rank recommendations. Example: top technology stories today. |
| `searchAlgorithm` | `string` | No | Ranking algorithm to apply. One of: most_recent, semantic, most_recent_semantic, trending. Defaults to semantic. |
| `similarityTopK` | `integer` | No | Number of top semantically similar items to consider. Min 1, max 1000. Defaults to 9. |
| `numResults` | `integer` | No | Number of recommendation results to return. Min 1, max 100. Defaults to 10. |
| `numArticlesRef` | `integer` | No | Minimum number of articles to return from the ref domain. Min 0 (0 = no domain-specific articles required), max 100. Defaults to 0. |
| `ref` | `string` | No | Site domain to prioritize for display in results (e.g. example.com). Optional. |
| `page` | `integer` | No | Result page number for pagination. Min 1. Defaults to 1. |
| `fields` | `string[]` | No | Optional allow-list of keys to keep on each returned article, to trim large payloads (e.g. title, url, summary, score). Omit to return every field. Available keys: author, image_url, preview_content, pubdate, pubdate_unix, score, site, site_domain, source_url, summary, title, url. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "dappier",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "dappier-get-ai-recommendations",
  arguments: {
    dataModelId: "Data Model ID",
    query: "Query",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "dappier-get-ai-recommendations",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    dappier: { authProvisionId: "apn_xxxxxxx" },
    dataModelId: "Data Model ID",
    query: "Query",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "dappier-get-ai-recommendations",
    "configured_props": {
      "dappier": { "authProvisionId": "apn_xxxxxxx" },
      "dataModelId": "Data Model ID",
      "query": "Query"
    }
  }'
```

---

- App: https://pipedream.com/apps/dappier.md · All apps: https://pipedream.com/apps
