CogniFlow is an advanced JavaScript library designed for seamless integration with major AI platforms. It enables programmatic interaction and real-time data extraction from AI interfaces through iframe embedding, query parameter injection, and postMessage communication. Automate and enhance your web-based AI interactions across platforms like ChatGPT, Claude, Gemini, Perplexity AI, Grok AI, Copilot, and Meta AI.
This library acts as a bridge, allowing web applications to deeply integrate with various AI services. It overcomes common cross-origin restrictions by leveraging iframe communication and manipulates external AI interfaces to extract responses and inject custom parameters, enabling powerful automation workflows.
mermaid graph TD A[Web Application] --> B(CogniFlow Library) B -- Manages Iframe Embeds --> C{AI Platform Iframe} B -- Injects Params/Queries --> C C -- AI Response --> D[MutationObserver/Scraping] D -- Parsed Data --> B B -- PostMessage Communication --> A B -- API Calls (Optional) --> E[External Services]
- 🚀 Project Overview
- 🏛️ Architecture
- 🤖 AI Agent Directives
- 🛠️ Core Features
- ⚙️ Installation & Setup
- 💡 Usage Examples
- 🤝 Contributing
- 📄 License
Click to Expand AI Agent Directives
Role: Apex Technical Authority & Elite Architect. Context: December 2025. Building for 2026 standards. Output Standard: EXECUTION-ONLY. Philosophy: "Zero-Defect, High-Velocity, Future-Proof."
- Semantic Correction: Infer technical intent from user inputs; do not execute literal typos. Reference the
README.mdas SSOT. - Mandatory MCP Instrumentation: Use
linkup/bravefor December 2025 standards/threats/trends. Usedocforkto verify APIs. Useclear-thought-twofor complex flows.
- PRIMARY SCENARIO: WEB / APP / EXTENSION (TypeScript/JavaScript)
- Stack: This project uses JavaScript (ESNext), heavily leveraging TypeScript 6.x (Strict) for development. Vite 7 (Rolldown) is used as the build tool. WXT (Web Extension Toolkit) is the standard for building browser extensions if this library were to be packaged as one. Biome is the unified tool for linting and formatting. Vitest for unit tests and Playwright for end-to-end testing.
- Architecture: Adheres to Feature-Sliced Design (FSD) for modularity and maintainability.
- State Management: Utilizes Signals (Standardized) for reactive state management.
- Testing: Vitest for unit/integration tests, Playwright for E2E tests.
- Formula:
<Product-Name>-<Primary-Function>-<Platform>-<Type> - Format:
Title-Case-With-Hyphens
- Sections: Visual Authority, Structural Clarity, AI Agent Directives, Development Standards.
- Badges:
flat-square,shields.io, Userchirag127, dynamic repo URL.
- Process: Audit -> Pivot/Archive -> Naming -> AI Directives -> File Generation -> Polish.
- Base URL:
https://github.com/chirag127/CogniFlow-AI-Platform-Integrator-And-Data-Extractor-Browser-Library - Consistency: Use the New Repo Name exclusively.
- Seamless Iframe Integration: Embeds AI platform interfaces directly within your web applications.
- Intelligent Query Injection: Programmatically injects search queries and parameters into AI interfaces.
- PostMessage Communication: Facilitates secure data exchange between your application and the AI interface.
- Real-time Response Scraping: Utilizes
MutationObserverto detect and extract AI responses as they are generated. - Multi-Platform Support: Designed to work with a wide range of popular AI platforms (ChatGPT, Claude, Gemini, Perplexity AI, Grok AI, Copilot, Meta AI, etc.).
- Robust Error Handling: Manages network issues, platform changes, and unexpected responses gracefully.
- TypeScript First: Developed with TypeScript for enhanced code quality, maintainability, and developer experience.
This library is intended to be used within a larger web application or browser extension project. Ensure you have a modern JavaScript/TypeScript development environment set up (e.g., using Vite, Webpack, or a similar bundler).
bash
git clone https://github.com/chirag127/CogniFlow-AI-Platform-Integrator-And-Data-Extractor-Browser-Library.git
npm install
yarn install
pnpm install
bash npm install @chirag127/cogniflow
yarn add @chirag127/cogniflow
pnpm add @chirag127/cogniflow
typescript import { CogniFlow } from '@chirag127/cogniflow';
const cogniFlow = new CogniFlow({ platformUrl: 'https://chat.openai.com/', // Example for ChatGPT apiKey: 'YOUR_API_KEY_IF_NEEDED_FOR_IFRAME_INIT', targetElementId: 'ai-chat-container' // DOM element to attach the iframe });
cogniFlow.onResponse(data => { console.log('AI Response:', data); // Process the extracted AI response });
async function sendMessage() { await cogniFlow.sendMessage('Hello, CogniFlow! What is the current weather?'); console.log('Message sent and response listener active.'); }
// Initialize and send message after DOM is ready cogniFlow.init().then(sendMessage).catch(error => { console.error('CogniFlow initialization failed:', error); });
typescript // Assume 'cogniFlow' is an initialized instance
const advancedParams = { temperature: 0.7, max_tokens: 150 };
async function sendAdvancedQuery() { await cogniFlow.sendMessage('Summarize the following text:', { injectionParams: { prompt_params: JSON.stringify(advancedParams) // Example: Injecting parameters } }); }
// Call sendAdvancedQuery() after initialization
Contributions are welcome! Please read our CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests.
This project is licensed under the CC BY-NC 4.0 License - see the LICENSE file for details.