Skip to content
reaatech

Files · Google Gemini Knowledge Agent for SurveyMonkey SMB Insights

65 (1 binary, 558.0 kB total)attempt 1

README.md·2477 B·markdown
markdown
# Google Gemini Knowledge Agent for SurveyMonkey SMB Insights
 
> Turn raw survey responses into an always‑available Q&A assistant that lets SMB owners ask natural‑language questions about customer feedback, powered by Google Gemini and vector search.
 
A tutorialized reference solution from [reaatech.com](https://reaatech.com), demonstrating how to build production-grade AI systems with the `@reaatech/*` package family.
 
## Architecture
 
SurveyMonkey API → chunk + embed via `@reaatech/agent-memory-embedding` → Qdrant vector store → Gemini LLM (`@google/genai`) → answer with citations. `@reaatech/agent-memory` manages conversation context; `@reaatech/llm-cache` caches embeddings.
 
```
SurveyMonkey REST API

SurveyMonkeyClient (src/surveymonkey/client.ts)

IngestionPipeline (src/ingest/embed.ts)
  → chunkResponses → embedChunks → storeChunksInQdrant → extractMemories

Qdrant (vector index) + AgentMemory (semantic memory)

POST /api/ask route handler (app/api/ask/route.ts)
  → MemoryRetriever + QdrantService.searchSimilar → GeminiService.generateAnswer
```
 
## Prerequisites
 
- Node.js >= 22
- pnpm (10.x)
- Redis instance (for embedding cache fallback)
- Qdrant instance (for vector storage)
- SurveyMonkey API access token
- OpenAI API key (for embedding providers)
- Google Gemini API key (for LLM)
 
## Getting Started
 
```bash
pnpm install
cp .env.example .env    # fill in your API keys and connection URLs
pnpm dev                # starts Next.js on port 3000
```
 
## API Reference
 
### `POST /api/ingest`
 
Ingest a SurveyMonkey survey's open-ended responses into the knowledge base.
 
**Request body:**
```json
{ "surveyId": "123456789", "accessToken": "<optional-override>" }
```
 
**Response (201):**
```json
{ "surveyId": "123456789", "chunksStored": 42, "status": "complete" }
```
 
### `POST /api/ask`
 
Ask a natural-language question against the ingested survey data.
 
**Request body:**
```json
{ "query": "What do customers think about our support?", "topK": 5, "surveyIds": ["123"] }
```
 
**Response (200):**
```json
{
  "answer": "Based on surveys, customers want faster response times.",
  "sources": [
    { "chunkId": "Q1", "snippet": "Support is slow...", "respondentId": "R42", "score": 0.95 }
  ]
}
```
 
## Testing
 
```bash
pnpm test          # vitest run --coverage
pnpm typecheck     # tsc --noEmit
pnpm lint          # eslint .
```
 
## License
 
MIT — see [LICENSE](./LICENSE).