### Initialize and Start Application Source: https://github.com/deepgram-starters/node-text-intelligence/blob/main/AGENTS.md Commands to clone submodules, install dependencies, and launch the backend and frontend servers. ```bash # Initialize (clone submodules + install deps) make init # Set up environment test -f .env || cp sample.env .env # then set DEEPGRAM_API_KEY # Start both servers make start # Backend: http://localhost:8081 # Frontend: http://localhost:8080 ``` -------------------------------- ### Initialize and Start Project with Makefile Source: https://github.com/deepgram-starters/node-text-intelligence/blob/main/README.md Use the Makefile for a streamlined local development setup. Ensure your DEEPGRAM_API_KEY is added to the .env file. ```bash make init cp sample.env .env # Add your DEEPGRAM_API_KEY make start ``` -------------------------------- ### Start and Stop Application Processes Source: https://github.com/deepgram-starters/node-text-intelligence/blob/main/AGENTS.md Commands for managing the application lifecycle, including starting services individually and cleaning the build environment. ```bash make start ``` ```bash # Terminal 1 — Backend node server.js # Terminal 2 — Frontend cd frontend && corepack pnpm run dev -- --port 8080 --no-open ``` ```bash lsof -ti:8080,8081 | xargs kill -9 2>/dev/null ``` ```bash rm -rf node_modules frontend/node_modules frontend/.vite make init ``` -------------------------------- ### Start Backend Server Source: https://github.com/deepgram-starters/node-text-intelligence/blob/main/README.md Run the backend server using Node.js. This command starts the server on port 8081. ```bash node --no-deprecation server.js ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/deepgram-starters/node-text-intelligence/blob/main/AGENTS.md Commands to install dependencies for the backend and frontend using corepack pnpm. ```bash corepack pnpm install Frontend: cd frontend && corepack pnpm install ``` -------------------------------- ### Start Frontend Server Source: https://github.com/deepgram-starters/node-text-intelligence/blob/main/README.md Start the frontend development server using pnpm. This command runs the frontend on port 8080 and prevents it from automatically opening in the browser. ```bash cd frontend && corepack pnpm run dev -- --port 8080 --no-open ``` -------------------------------- ### Clone and Install Project with Node.js and pnpm Source: https://github.com/deepgram-starters/node-text-intelligence/blob/main/README.md Clone the repository, install dependencies using pnpm, and configure your Deepgram API key. This method requires manual server startup. ```bash git clone --recurse-submodules https://github.com/deepgram-starters/node-text-intelligence.git cd node-text-intelligence pnpm install cd frontend && pnpm install && cd .. cp sample.env .env # Add your DEEPGRAM_API_KEY ``` -------------------------------- ### Get application metadata Source: https://context7.com/deepgram-starters/node-text-intelligence/llms.txt Retrieves application configuration details and metadata from the server. ```bash curl -X GET http://localhost:8081/api/metadata ``` -------------------------------- ### Conventional Commit Examples Source: https://github.com/deepgram-starters/node-text-intelligence/blob/main/AGENTS.md Standardized commit message formats for project contributions. ```text feat(node-text-intelligence): add diarization support fix(node-text-intelligence): resolve WebSocket close handling refactor(node-text-intelligence): simplify session endpoint chore(deps): update frontend submodule ``` -------------------------------- ### Get Application Metadata Source: https://context7.com/deepgram-starters/node-text-intelligence/llms.txt Retrieves metadata about the application, including its title, description, SDK version, and tags. ```APIDOC ## GET /api/metadata ### Description Returns application metadata from deepgram.toml including title, description, SDK version, and tags. ### Method GET ### Endpoint /api/metadata ### Response #### Success Response (200) - **title** (string) - The title of the application. - **description** (string) - A description of the application. - **author** (string) - The author of the application. - **repository** (string) - The URL of the application's repository. - **useCase** (string) - The primary use case of the application. - **language** (string) - The programming language used. - **framework** (string) - The framework used. - **sdk** (string) - The version of the SDK used. - **tags** (array of strings) - Tags associated with the application. #### Response Example ```json { "title": "Node Text Intelligence", "description": "Get started using Deepgram's Text Intelligence with this Node demo app", "author": "Deepgram DX Team ", "repository": "https://github.com/deepgram-starters/node-text-intelligence", "useCase": "text-intelligence", "language": "javascript", "framework": "node", "sdk": "4.11.3", "tags": ["text-intelligence", "text-analysis", "nlp"] } ``` ``` -------------------------------- ### Configure environment variables Source: https://context7.com/deepgram-starters/node-text-intelligence/llms.txt Sets up the required environment variables for the application, including the mandatory Deepgram API key. ```bash cp sample.env .env # Required: Set your Deepgram API key DEEPGRAM_API_KEY=your_api_key_here # Optional: Configure server port (default: 8081) PORT=8081 # Optional: Configure server host (default: 0.0.0.0) HOST=0.0.0.0 # Optional: Set session secret for JWT signing (auto-generated if not set) SESSION_SECRET=your_secret_key_here ``` -------------------------------- ### Integrate Deepgram SDK in Node.js Source: https://context7.com/deepgram-starters/node-text-intelligence/llms.txt Demonstrates initializing the Deepgram client and performing text analysis using the Node.js SDK. ```javascript const { createClient } = require("@deepgram/sdk"); // Initialize the Deepgram client const deepgram = createClient(process.env.DEEPGRAM_API_KEY); // Analyze text with multiple features async function analyzeText(textContent) { const options = { language: 'en', summarize: true, topics: true, sentiment: true, intents: true }; const { result, error } = await deepgram.read.analyzeText( { text: textContent }, options ); if (error) { console.error('Deepgram API Error:', error); throw new Error(error.message || 'Failed to process text'); } return result.results; } // Example usage const text = "Customer feedback indicates high satisfaction with the new features."; analyzeText(text) .then(results => console.log(JSON.stringify(results, null, 2))) .catch(err => console.error(err)); ``` -------------------------------- ### Analyze content from a URL Source: https://context7.com/deepgram-starters/node-text-intelligence/llms.txt Fetches and analyzes text content directly from a provided URL. ```bash curl -X POST "http://localhost:8081/api/text-intelligence?summarize=true&topics=true" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "url": "https://example.com/article.txt" }' ``` -------------------------------- ### Testing and Endpoint Verification Commands Source: https://github.com/deepgram-starters/node-text-intelligence/blob/main/AGENTS.md Commands to execute conformance tests and manually verify API endpoints using curl. ```bash # Run conformance tests (requires app to be running) make test # Manual endpoint check curl -sf http://localhost:8081/api/metadata | python3 -m json.tool curl -sf http://localhost:8081/api/session | python3 -m json.tool ``` -------------------------------- ### Analyze text with all features enabled Source: https://context7.com/deepgram-starters/node-text-intelligence/llms.txt Performs a POST request to the text-intelligence endpoint with all analysis features enabled via query parameters. ```bash curl -X POST "http://localhost:8081/api/text-intelligence?summarize=true&topics=true&sentiment=true&intents=true&language=en" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "text": "Our customer support team has been receiving many complaints about the new update. Users are frustrated with the changes to the interface and are requesting that we revert to the previous version. We need to address these concerns quickly to maintain customer satisfaction." }' ``` -------------------------------- ### Analyze Text with Summarization Source: https://context7.com/deepgram-starters/node-text-intelligence/llms.txt Generates a summary of the provided text. The summarize parameter supports 'true' or 'v2'. ```bash # Analyze text with summarization enabled curl -X POST "http://localhost:8081/api/text-intelligence?summarize=true" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "text": "Deepgram'\''s Text intelligence API can extract insights from written content. It can perform tasks like summarization, sentiment analysis, topic detection, and intent recognition. These capabilities are useful for a wide range of applications including customer service, content moderation, and business intelligence." }' # Response: # { # "results": { # "summary": { # "text": "Deepgram's Text Intelligence API extracts insights from content for applications like customer service and business intelligence." # } # } # } ``` -------------------------------- ### Node.js SDK Integration Source: https://context7.com/deepgram-starters/node-text-intelligence/llms.txt Demonstrates how to integrate Deepgram's Text Intelligence capabilities directly into a Node.js application using the official SDK. ```APIDOC ## Node.js SDK Integration ### Description Direct usage of the Deepgram SDK for text intelligence analysis in Node.js applications. ### Code Example ```javascript const { createClient } = require("@deepgram/sdk"); // Initialize the Deepgram client const deepgram = createClient(process.env.DEEPGRAM_API_KEY); // Analyze text with multiple features async function analyzeText(textContent) { const options = { language: 'en', summarize: true, topics: true, sentiment: true, intents: true }; const { result, error } = await deepgram.read.analyzeText( { text: textContent }, options ); if (error) { console.error('Deepgram API Error:', error); throw new Error(error.message || 'Failed to process text'); } return result.results; } // Example usage const text = "Customer feedback indicates high satisfaction with the new features."; analyzeText(text) .then(results => console.log(JSON.stringify(results, null, 2))) .catch(err => console.error(err)); ``` ``` -------------------------------- ### Update Frontend Submodule Source: https://github.com/deepgram-starters/node-text-intelligence/blob/main/AGENTS.md Workflow for committing and pushing changes made within the frontend git submodule. ```bash cd frontend && git add . && git commit -m "feat: description" cd frontend && git push origin main cd .. && git add frontend && git commit -m "chore(deps): update frontend submodule" ``` -------------------------------- ### Analyze Text with Topic Detection Source: https://context7.com/deepgram-starters/node-text-intelligence/llms.txt Extracts topics and themes from text, returning detected topics along with their confidence scores. ```bash # Analyze text with topic detection curl -X POST "http://localhost:8081/api/text-intelligence?topics=true" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "text": "Machine learning models are being used to improve natural language processing. Deep learning techniques have revolutionized how computers understand human speech and text." }' # Response: # { # "results": { # "topics": { # "segments": [ # { # "text": "Machine learning models...", # "topics": [ # {"topic": "machine learning", "confidence": 0.95}, # {"topic": "natural language processing", "confidence": 0.89} # ] # } # ] # } # } # } ``` -------------------------------- ### Retrieve Session Token Source: https://context7.com/deepgram-starters/node-text-intelligence/llms.txt Fetches a JWT token for API authentication. The token must be included in the Authorization header as a Bearer token for subsequent requests. ```bash # Request a session token curl -X GET http://localhost:8081/api/session # Response: # {"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."} # Store token for subsequent requests TOKEN=$(curl -s http://localhost:8081/api/session | jq -r '.token') echo $TOKEN ``` -------------------------------- ### Analyze Text with Intent Detection Source: https://context7.com/deepgram-starters/node-text-intelligence/llms.txt Identifies user intents within the provided text to help determine desired actions or outcomes. ```bash # Analyze text with intent detection curl -X POST "http://localhost:8081/api/text-intelligence?intents=true" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "text": "I would like to cancel my subscription and get a refund for the remaining months." }' # Response: # { # "results": { # "intents": { # "segments": [ # { # "text": "I would like to cancel my subscription...", # "intents": [ # {"intent": "cancel_subscription", "confidence": 0.94}, # {"intent": "request_refund", "confidence": 0.88} # ] # } # ] # } # } # } ``` -------------------------------- ### Analyze Content from URL Source: https://context7.com/deepgram-starters/node-text-intelligence/llms.txt Fetches text content from a specified URL and performs analysis. The API validates the URL and handles fetch errors. ```APIDOC ## POST /api/text-intelligence (URL) ### Description Fetches text content from a URL and analyzes it. The API validates the URL format and handles fetch errors gracefully. ### Method POST ### Endpoint /api/text-intelligence ### Query Parameters - **summarize** (boolean) - Optional - Whether to enable summarization. - **topics** (boolean) - Optional - Whether to enable topic extraction. ### Request Body - **url** (string) - Required - The URL of the content to analyze. ### Request Example ```json { "url": "https://example.com/article.txt" } ``` ### Response #### Success Response (200) - **results** (object) - Contains the analysis results for enabled features (summary, topics). #### Response Example ```json { "results": { "summary": { "text": "..." }, "topics": { "segments": [...] } } } ``` #### Error Response - **error** (object) - Details about the error if the URL is invalid or fetching fails. #### Error Response Example ```json { "error": { "type": "validation_error", "code": "INVALID_URL", "message": "Invalid URL format", "details": {} } } ``` ``` -------------------------------- ### Analyze Text with All Features Enabled Source: https://context7.com/deepgram-starters/node-text-intelligence/llms.txt This endpoint analyzes provided text using all available features like summarization, topic extraction, sentiment analysis, and intent recognition. Query parameters control which features are enabled. ```APIDOC ## POST /api/text-intelligence ### Description Analyzes provided text with all features enabled, including summarization, topic extraction, sentiment analysis, and intent recognition. ### Method POST ### Endpoint /api/text-intelligence ### Query Parameters - **summarize** (boolean) - Optional - Whether to enable summarization. - **topics** (boolean) - Optional - Whether to enable topic extraction. - **sentiment** (boolean) - Optional - Whether to enable sentiment analysis. - **intents** (boolean) - Optional - Whether to enable intent recognition. - **language** (string) - Optional - The language of the text (e.g., 'en'). ### Request Body - **text** (string) - Required - The text content to analyze. ### Request Example ```json { "text": "Our customer support team has been receiving many complaints about the new update. Users are frustrated with the changes to the interface and are requesting that we revert to the previous version. We need to address these concerns quickly to maintain customer satisfaction." } ``` ### Response #### Success Response (200) - **results** (object) - Contains the analysis results for enabled features (summary, topics, sentiments, intents). #### Response Example ```json { "results": { "summary": { "text": "..." }, "topics": { "segments": [...] }, "sentiments": { "segments": [...], "average": {...} }, "intents": { "segments": [...] } } } ``` ``` -------------------------------- ### Check service health Source: https://context7.com/deepgram-starters/node-text-intelligence/llms.txt Retrieves the current health status of the service for monitoring purposes. ```bash curl -X GET http://localhost:8081/health ``` -------------------------------- ### Analyze Text with Sentiment Analysis Source: https://context7.com/deepgram-starters/node-text-intelligence/llms.txt Performs sentiment analysis on text, providing classifications and confidence scores for segments and the overall text. ```bash # Analyze text with sentiment analysis curl -X POST "http://localhost:8081/api/text-intelligence?sentiment=true" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "text": "I absolutely love this product! It has exceeded all my expectations and the customer service was fantastic." }' # Response: # { # "results": { # "sentiments": { # "segments": [ # { # "text": "I absolutely love this product!", # "sentiment": "positive", # "sentiment_score": 0.92 # } # ], # "average": { # "sentiment": "positive", # "sentiment_score": 0.92 # } # } # } # } ``` -------------------------------- ### Health Check Endpoint Source: https://context7.com/deepgram-starters/node-text-intelligence/llms.txt Provides the service health status, useful for monitoring and load balancer checks. ```APIDOC ## GET /health ### Description Returns the service health status for monitoring and load balancer health checks. ### Method GET ### Endpoint /health ### Response #### Success Response (200) - **status** (string) - The health status of the service (e.g., "ok"). - **service** (string) - The name of the service. #### Response Example ```json { "status": "ok", "service": "text-intelligence" } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.