Automate Conversations API implementation with an AI skill

Last updated:

If your development team uses an AI coding assistant like Claude Code or Cursor, you can use the Pendo setup-agent-analytics skill to automate Conversations API implementations instead of adding trackAgent() calls to your codebase manually.

The skill scans your project, detects your AI agents and project framework, and adds the appropriate tracking calls for prompts, responses, and visitor reactions. It supports both client-side and server-side implementation, and selects the correct method based on your environment.

Prerequisites

Before using the skill, make sure:

  • Claude Code or Cursor is installed and running in your development environment.
  • For client-side implementation, the Pendo Web SDK is installed in your application and window.pendo is available in the browser runtime.
  • For server-side implementation, the Track Event shared secret for the application your agent is associated with. For retrieval steps, see Send conversation events on the server side.
  • An AI agent is set up in Pendo with full conversations activated. For setup steps, see Add and configure AI agents in Pendo.
  • You have the Agent ID ready to use. To find it, go to Product > Agent Analytics, then select the settings (cog) icon next to the agent name.

Install the skill

Download the setup-agent-analytics skill file and add it to your preferred AI coding assistant. For installation steps, see the documentation for your tool. For example:

Run the skill

Open your AI coding assistant in the root of the project that contains your AI agent. You can run the skill in two ways:

  • Use the slash command: /setup-agent-analytics.
  • Ask the assistant directly to use the skill (for example, "Use the setup-agent-analytics skill to instrument my AI agent with Pendo tracking").

If you have your Agent ID ready, pass it as an argument:

/setup-agent-analytics agent_abc123

If your application has multiple AI agents, pass multiple Agent IDs separated by spaces. The skill assigns them to agents in the order it discovers them:

/setup-agent-analytics agent_abc123 agent_def456

If you don't have your Agent ID yet, you can run the skill without arguments. The skill uses a placeholder value (YOUR_AGENT_ID) that you replace later.

What the skill does

The skill runs in three phases. It pauses between Phase 2 and Phase 3 to let you review its findings before it makes any code changes.

Phase 1: Detect your project framework

The skill identifies your project framework and determines where to search for agents and how to handle environment-specific considerations like server-side rendering boundaries. It also determines whether to use client-side or server-side instrumentation based on your environment.

Phase 2: Find your AI agents

The skill scans for LLM SDK usage (OpenAI, Anthropic, Google AI, LangChain, Vercel AI SDK, and others), then traces imports to find the conversation orchestration layer, which is the component or service that manages chat sessions, handles user input, and returns AI responses.

For each agent it finds, the skill reports the:

  • Agent name and description.
  • Main orchestration file.
  • LLM provider.
  • Instrumentation method (client-side or server-side).
  • Entry points where prompts are submitted.
  • Response handlers where responses complete.
  • Feedback handlers where reactions are collected (if applicable).
  • CSS selectors for the chat input and submit button (client-side only).

The skill also detects optional metadata from your codebase, such as the model used, suggested prompts, tool calls, and file uploads, and includes them in tracking calls where available.

Review these findings carefully before confirming. The skill asks for your approval before proceeding to Phase 3.

Phase 3: Instrument with trackAgent()

After you confirm the findings, the skill adds instrumentation to your codebase:

  • Creates a helper function in a shared utilities file (for example, src/utils/pendo.ts). This helper wraps the tracking call with guards for SSR environments, truncates content to 500 characters, and handles silent errors so analytics never affect your product.
  • Adds prompt tracking in each agent's submit handler, firing a prompt event before the API call.
  • Adds response tracking where each agent's response completes (after streaming finishes or the response resolves), firing an agent_response event.
  • Adds reaction tracking if your agent has a feedback UI (such as thumbs up or thumbs down), firing a user_reaction event.
  • Manages conversation and message IDs. The skill reuses your existing conversation or session IDs when available, or generates them with crypto.randomUUID(). Conversation IDs persist across all messages in a session. Message IDs are unique for each message.

After instrumentation, the skill presents a summary table showing every tracking call it added, which file and function it lives in, and which Agent ID it used.

Important: If you ran the skill without providing Agent IDs, search your codebase for YOUR_AGENT_ID and replace each instance with the real Agent ID from your agent's settings before deploying. Placeholder IDs don't send data to Pendo.

Verify your implementation

After the skill finishes, deploy your changes and verify that data is flowing into Pendo. Start by interacting with your AI agent in a development environment where the Pendo Web SDK is loaded (or where your server-side configuration is active). Submit a prompt, wait for the response, and provide feedback if your agent supports it.
Then use any of the following methods to confirm data is reaching Pendo:

  • Check for events using the Pendo debugger. Open your browser's developer console, run pendo.enableDebugging(), and open the Events tab. Select Start event logging, then submit a prompt to your agent. Verify that prompt and agent_response events appear in the event log. Events may take up to 15 minutes to appear after your first interaction. For more information on using the debugger, see Test your agent setup.
  • Check the Raw Events tab. If you have permission to view raw events, you can also verify that events are reaching Pendo by going to Settings > Subscription settings > Applications from the top-right corner of Pendo, selecting the app, and opening the Raw Events tab.
  • View data in Agent Analytics. Conversation data is processed in hourly batches. After your code is live in production, new messages typically appear within 15 minutes after the start of the next batch. Go to Product > Agent Analytics, select your agent, and open the Conversations tab to confirm that both visitor prompts and agent responses appear.

Note: If your application retries API calls or replays events, make sure you reuse the same messageId to avoid duplicate records in Pendo.

Was this article helpful?
0 out of 0 found this helpful