Connect Cognism to AI Agents: Automate Prospecting and Compliance
Learn how to connect Cognism to AI Agents using Truto's /tools endpoint. Build autonomous workflows for B2B prospecting, data enrichment, and compliance checks.
You want to connect Cognism to an AI agent so your system can autonomously search for B2B prospects, enforce opt-out compliance, enrich account records, and redeem high-value contact data. Here is exactly how to do it using Truto's /tools endpoint and SDK, bypassing the need to build and maintain a custom Cognism API integration from scratch.
Giving a Large Language Model (LLM) read and write access to your revenue intelligence stack is an engineering headache. You either spend weeks building, hosting, and maintaining a custom connector, or you use a managed infrastructure layer that handles the boilerplate for you. If your team uses ChatGPT, check out our guide on connecting Cognism to ChatGPT, or if you are building on Anthropic's models, read our guide on connecting Cognism to Claude. For developers building custom autonomous workflows, you need a programmatic way to fetch these tools and bind them to your agent framework.
This guide breaks down exactly how to fetch AI-ready tools for Cognism, bind them natively to an LLM using LangChain (or any framework like LangGraph, CrewAI, or Vercel AI SDK), and execute complex go-to-market workflows. For a broader look at this design pattern and why custom integration code stalls AI projects, read our research on architecting AI agents and the SaaS integration bottleneck.
The Engineering Reality of the Cognism API
Giving an LLM access to external data sounds simple in a prototype. You write a Node.js function that makes a fetch request and wrap it in an @tool decorator. In production against complex enterprise intelligence platforms, this approach collapses.
Cognism's API introduces several specific integration challenges that break standard REST assumptions. If you hardcode these interactions into your agent, you will spend your sprints writing defensive integration code instead of improving your model's reasoning capabilities.
The Search - Preview - Redeem Architecture Trap
Most LLMs are prompted with a fundamental assumption about external data: if you ask for a contact's email, the API will return the contact's email. Cognism does not work this way.
Cognism operates on a credit-based entitlement system. The API enforces a strict three-step lifecycle: Search, Enrich/Preview, and Redeem. When your agent queries the /search/contacts endpoint, the API does not return phone numbers or email addresses. It returns boolean preview flags like hasEmail and hasMobilePhone.
If you expose the raw API to an LLM, the model will frequently hallucinate contact data because it expects the search response to contain the actual string values. When it sees hasEmail: true, it might confidently invent an email address to satisfy the user prompt. To get the actual data, the agent must extract the id from the search response and make a secondary request to the /contacts/redeem endpoint. Orchestrating this multi-hop logic requires strict JSON schemas and well-defined tool descriptions so the LLM understands it must spend credits to reveal the data.
The HTTP Status Compliance Quirks
Handling compliance checks - specifically opt-outs - introduces another conceptual hurdle for LLMs. When querying the Cognism compliance endpoints to check if an email has opted out of communications, the API uses HTTP status codes as the primary data payload.
A response of HTTP 200 OK means the contact has opted out (they are on the suppression list). A response of HTTP 404 Not Found means the contact has not opted out (they are safe to contact). Standard LLM tool-calling execution assumes a 404 is a system error or a hallucinated parameter. If your agent framework catches the 404 and throws an exception, the LLM will incorrectly assume the tool failed, rather than correctly interpreting that the prospect is legally safe to email.
Complex Array Filtering
Cognism's search endpoints are highly powerful but demand complex payload structures. A search query for accounts can accept up to 1,000 terms per array field (names, domains, industries, technologies). If an LLM attempts to send a flat string like "technology": "Salesforce" instead of the required array structure "technologies": ["Salesforce"], the API will reject the request.
Truto abstracts these quirks. By querying Truto's /tools endpoint, your system receives Proxy APIs - pre-configured methods mapped to Cognism's resources. Truto handles the authentication lifecycle and provides strict, normalized JSON schemas that prevent the LLM from making structural payload errors.
Hero Tools for Cognism AI Agents
Instead of overwhelming your LLM's context window with dozens of raw endpoints, Truto surfaces specific, highly leveraged tools. By providing the LLM with exact descriptions and strict parameter typing, you eliminate parameter hallucinations.
Here are the hero tools you should expose to your AI agent for Cognism automation.
list_all_cognism_search_contacts
This tool enables the agent to search the Cognism database for prospects based on granular criteria like job title, location, seniority, skills, and account attributes. It returns preview data (names, titles, account IDs) and boolean flags indicating data availability. It is strictly a discovery tool - it does not spend credits or return contact information.
"Find me 15 Vice Presidents of Engineering located in the United Kingdom who have skills in 'Cloud Computing' or 'Kubernetes'. Return their internal Cognism IDs and verify if they have mobile phone data available."
cognism_contacts_redeem
This is the execution tool. It takes an array of redeemIds (obtained from the search or enrich tools) and spends your organization's Cognism credits to unlock the full contact record, including verified email addresses and direct dial phone numbers.
"Take the 5 contact IDs you just found for the VPs of Engineering and redeem them to extract their direct phone numbers and corporate email addresses. Compile the final list for my outreach sequence."
cognism_accounts_enrich
This tool allows the agent to take sparse company data (like a raw website domain or a LinkedIn URL) and enrich it against Cognism's database. It returns a scored match preview. It defaults to a minimum match score of 40, protecting your system from associating leads with the wrong corporate entities.
"I have a list of domains: 'acme.com' and 'globex.io'. Enrich these accounts in Cognism and tell me their industry classifications and estimated revenue bands based on the highest confidence match."
cognism_filters_search_technologies
B2B sales agents often need to target accounts based on their tech stack. This tool allows the agent to search Cognism's massive index of supported technology filters to find the exact internal key required for account searches.
"Search the Cognism technology filters for 'Datadog' and 'New Relic'. Retrieve their exact index keys so we can use them to build a target list of accounts using these observability tools."
list_all_cognism_search_accounts
This tool executes account-level searches. It accepts arrays of names, domains, industries, technologies, and company sizes. It returns matching account records with preview flags indicating available data points, allowing the agent to map out total addressable market (TAM) segments before redeeming individual contacts.
"Search for all enterprise accounts in the 'Financial Services' industry located in 'New York' with a headcount greater than 1000. Give me the top 20 accounts."
cognism_compliance_get_opt_out_by_email
Critical for autonomous outbound systems, this tool checks whether a specific email address exists on your Cognism opt-out list. It allows the agent to build safe, compliant workflow logic before passing leads to an outreach sequencer.
"Before we send the draft email to 'jdoe@example.com', check the Cognism compliance registry to ensure they have not previously opted out of our communications."
To view the complete inventory of available tools, query parameters, and schema definitions, visit the Cognism integration page.
Workflows in Action
Connecting Cognism to AI Agents allows you to move beyond basic chatbots and build asynchronous, multi-step revenue operations pipelines. When the agent has access to a unified tool layer, it can execute complex decision trees autonomously.
Here are two concrete examples of workflows you can build today.
Scenario 1: The Autonomous ABM Prospector
User Prompt:
"Build a target list for our new cybersecurity product. Find 10 companies in the finance sector using 'Okta'. For those companies, find the CISO or VP of Security, check if they are on our opt-out list, and if they are clear, redeem their contact info and format it as a CSV."
Agent Execution Sequence:
cognism_filters_search_technologies: The agent searches for "Okta" to get the correct internal ID for the technology filter.list_all_cognism_search_accounts: The agent executes a search using the Okta technology ID and the "Finance" industry filter, requesting 10 results.list_all_cognism_search_contacts: Iterating over the retrieved account IDs, the agent searches for contacts with seniority levels matching "C-Suite" or "VP" and job titles containing "Security" or "CISO".cognism_compliance_get_opt_out_by_email: Wait, the agent realizes it doesn't have the emails yet to check compliance. The agent uses its reasoning to realize it must redeem first.cognism_contacts_redeem: The agent passes theredeemIdsto unlock the emails.cognism_compliance_get_opt_out_by_email: The agent checks the newly retrieved emails against the opt-out list, discarding any that return a 200 OK status.- The agent formats the remaining clean, verified contacts into a CSV string.
Result: The user receives a fully enriched, legally compliant list of highly targeted prospects, completely bypassing manual list building.
Scenario 2: Inbound Lead Enrichment & Routing
User Prompt:
"A new lead just filled out our demo form: Sarah Jenkins, Product Manager at segment.com. Enrich this account to find their revenue and headcount, find Sarah's direct phone number, and draft a personalized intro email based on her company's industry."
Agent Execution Sequence:
cognism_accounts_enrich: The agent queries the domain "segment.com" to retrieve the core company data, including industry ("B2B SaaS") and size.list_all_cognism_search_contacts: The agent searches for "Sarah Jenkins" at the enriched Account ID to locate her specific profile and obtain herredeemId.cognism_contacts_redeem: The agent redeems the ID to acquire her mobile phone number and verified email.- The agent uses its internal LLM capabilities to synthesize the industry data and draft a highly contextualized email, returning both the phone number for the SDR and the drafted copy.
Result: An SDR receives a fully fleshed-out profile and a ready-to-send email within seconds of an inbound form submission.
Building Multi-Step Workflows
To build these systems, your code needs to reliably fetch the tools, register them with the LLM, and execute a loop that handles tool calls, responses, and potential rate limits.
Using the truto-langchainjs-toolset, you can dynamically inject Cognism tools into any LangChain agent. This approach is framework-agnostic at the API level - whether you use LangChain, LangGraph, or the Vercel AI SDK, the core architecture remains the same.
Fetching and Binding Tools
First, you initialize the Truto Tool Manager and bind the proxy APIs to your LLM.
import { ChatOpenAI } from "@langchain/openai";
import { TrutoToolManager } from "truto-langchainjs-toolset";
import { AgentExecutor, createToolCallingAgent } from "langchain/agents";
import { ChatPromptTemplate } from "@langchain/core/prompts";
// Initialize the Truto Tool Manager for your specific Cognism integration
const toolManager = new TrutoToolManager({
trutoApiKey: process.env.TRUTO_API_KEY,
integratedAccountId: process.env.COGNISM_INTEGRATED_ACCOUNT_ID,
});
async function runAgent() {
// 1. Fetch Cognism tools dynamically from Truto
const tools = await toolManager.getTools();
// 2. Initialize your LLM
const llm = new ChatOpenAI({
modelName: "gpt-4o",
temperature: 0,
});
// 3. Bind tools to the LLM
const llmWithTools = llm.bindTools(tools);
// 4. Create the prompt and agent
const prompt = ChatPromptTemplate.fromMessages([
["system", "You are a revenue operations assistant. You have access to Cognism to search, enrich, and redeem prospect data. Always check compliance before finalizing outreach lists."],
["human", "{input}"],
["placeholder", "{agent_scratchpad}"],
]);
const agent = createToolCallingAgent({
llm: llmWithTools,
tools,
prompt,
});
const executor = new AgentExecutor({
agent,
tools,
maxIterations: 10,
});
const result = await executor.invoke({
input: "Find 5 CTOs at software companies in London, redeem their info, and check their opt-out status."
});
console.log(result.output);
}Handling Rate Limits and Execution Failures
When building autonomous agents, developers often assume the integration layer will magically handle API rate limits.
It is a critical factual requirement to understand how Truto handles rate limits: Truto does not retry, throttle, or apply backoff on rate limit errors. When the upstream Cognism API returns an HTTP 429 Too Many Requests, Truto passes that exact error back to the caller.
However, Truto abstracts the pain of vendor-specific header parsing. It normalizes upstream rate limit information into standardized headers (ratelimit-limit, ratelimit-remaining, ratelimit-reset) per the IETF specification.
Your agent framework must be responsible for catching tool execution failures, reading these headers, and pausing execution. If you do not implement backoff in your agent loop, a fast-running LLM will rapidly burn through your rate limits and fail the entire workflow.
sequenceDiagram
participant Agent as "AI Agent"
participant Truto as "Truto Proxy"
participant Cognism as "Cognism API"
Agent->>Truto: Call cognism_contacts_redeem(redeemIds)
Truto->>Cognism: POST /contacts/redeem
Cognism-->>Truto: 429 Too Many Requests<br>X-RateLimit-Reset: 1710000000
Truto-->>Agent: 429 Too Many Requests<br>ratelimit-reset: 1710000000
Note over Agent: Agent catches 429.<br>Reads 'ratelimit-reset'.<br>Sleeps thread until reset time.
Agent->>Truto: Retry cognism_contacts_redeem(redeemIds)
Truto->>Cognism: POST /contacts/redeem
Cognism-->>Truto: 200 OK (Data Payload)
Truto-->>Agent: 200 OK (Standardized JSON)If you are using a framework like LangGraph for complex workflows, you should implement a custom tool node that wraps the Truto tool execution in a try/catch block. When a 429 is caught, parse the ratelimit-reset header, calculate the wait time, and either sleep the thread or return a state indicating the agent should pause and yield control back to the orchestrator.
By pushing the retry responsibility to your application logic while relying on Truto for schema enforcement and auth, you maintain total control over your agent's behavior and cost, without drowning in vendor-specific API documentation.
Moving Beyond Point-to-Point Integrations
Connecting an AI agent to a single tool like Cognism is a great prototype. But production go-to-market systems require orchestrating data across multiple platforms - searching Cognism, creating records in Salesforce, enrolling contacts in Outreach, and logging activity in Slack.
Building separate custom integrations for every one of those tools guarantees technical debt. By utilizing a unified API layer and proxy endpoints, you can collapse your entire integration surface area into a single, predictable toolset for your LLM.
FAQ
- How does Truto handle Cognism API rate limits?
- Truto does not automatically retry, throttle, or apply backoff on rate limit errors. When Cognism returns an HTTP 429, Truto passes that error to your agent. However, Truto normalizes the upstream rate limit data into standard IETF headers (`ratelimit-limit`, `ratelimit-remaining`, `ratelimit-reset`) so your application can cleanly implement its own retry logic.
- Do I have to build JSON schemas for the Cognism AI agent tools?
- No. Truto's `/tools` endpoint automatically generates strict, normalized JSON schemas and descriptions for all available Cognism proxy APIs. You can bind these directly to your LLM using frameworks like LangChain without writing manual schema definitions.
- How does the agent know when to spend Cognism credits vs just searching?
- The tools are separated into distinct actions. Tools like `list_all_cognism_search_contacts` only return preview data and cost no credits. The `cognism_contacts_redeem` tool description explicitly instructs the LLM that it will spend credits to unlock full data. The LLM's reasoning engine will read these descriptions and orchestrate the flow accordingly.
- Can I filter Cognism searches using the AI agent?
- Yes. The search tools support complex array filtering for attributes like job titles, industries, headcount, and technologies. Truto provides helper tools (like `cognism_filters_search_technologies`) so the agent can discover the correct internal IDs to build highly targeted search payloads.