Link Menu Expand (external link) Document Search Copy Copied

Claude Text Agent

Definition

The Claude Text Agent action allows you to leverage Anthropic’s powerful Claude AI models directly within your zenphi flows to analyze, classify, extract, summarize, and generate text using your own Anthropic API key. This action is designed for high-reasoning tasks and complex document intelligence, giving you granular control over the AI’s behavior through system instructions and dynamic prompting. Key capabilities include:

  • Processing complex prompts alongside attached files (such as .pdf, .jpg, or .csv files) for deep analysis and summarization.
  • Enforcing structured data extraction or raw JSON outputs to ensure the AI’s response is perfectly formatted for your automated processes.
  • Utilizing advanced reasoning features, including step-by-step “extended thinking” and example-based learning, to handle highly sophisticated research or creative generation tasks.

This action brings high-level artificial intelligence reasoning into your automated workflows, making it incredibly easy to transform unstructured data into actionable, structured insights for downstream steps.

Inputs

1. Model:

  • Purpose: Select which specific Claude AI model (e.g., Haiku 4.5, Opus 4.6, Sonnet 4.6) you want to use to generate the response.
  • Practical Guidance: You typically select this from a dropdown list as a static value, choosing the model that best balances speed, cost, and intelligence for your specific workflow.
  • Use Case Context: You would use the “Model” field to select a faster model like Haiku for quick text classifications, or a more powerful model like Opus for complex logical reasoning.

2. API Key:

  • Purpose: Authenticates your zenphi flow with your Anthropic account so you have permission to access the Claude models.
  • How to Obtain Your Key:
    1. Go to the and log in or sign up.
    2. Navigate to API Keys in the left-hand menu.
    3. Click Create Key, give it a name (e.g., “Zenphi Integration”), and generate it.
    4. Copy the key immediately and store it securely, as Anthropic will only display it once.
    5. Navigate to Settings > Billing to add payment details and initial credits, as the key requires an active billing account to function.
  • Practical Guidance: You can paste your Anthropic API key directly as a static value, or securely pass it in dynamically using the token picker (chain icon) from a secure vault or a previous step.
  • Use Case Context: You need the “API Key” field to grant the action permission to execute AI tasks and bill them to your Anthropic account.

3. System Instructions:

  • Purpose: Sets the overarching persona, rules, tone, and style for the AI model to follow during the interaction.
  • Practical Guidance: Type a static set of instructions (e.g., “You are a helpful legal assistant”) or use the token picker to dynamically insert rules based on the current workflow context.
  • Use Case Context: You would use “System Instructions” to ensure Claude always responds in a professional, concise tone suitable for customer-facing emails.

4. Prompt:

  • Purpose: The actual question, command, or instruction you want the AI to execute.
  • Practical Guidance: This is usually a combination of static text and dynamic values from the token picker, such as typing “Summarize this email:” and then inserting the email body token from your workflow trigger.
  • Use Case Context: You would use the “Prompt” field to ask Claude to extract specific invoice details from a provided block of text.

5. Files:

  • Purpose: Allows you to attach documents or images (like .pdf, .jpg, or text files) for the AI to read, analyze, and process alongside your prompt.
  • Practical Guidance: You provide this dynamically by using the token picker to select a file object or a collection of files outputted from a previous step (like a Google Drive Find File/Folder action).
  • Use Case Context: You would use the “Files” field to pass a scanned contract to Claude so it can summarize the key legal clauses.

6. Enable This Toggle to Use Collection Mapping:

  • Purpose: Turns on the ability to load example data dynamically from sources like tables or spreadsheets to guide the AI’s behavior.
  • Practical Guidance: Simply click the toggle to turn it on (a static choice).
  • Use Case Context: You would enable this toggle if you want to feed Claude a dynamic list of examples from a Google Sheet to help it understand the exact output format you expect.

7. Use Example-Based Responses:

  • Purpose: Allows you to manually provide “few-shot” examples to train the agent on your specific formatting or logic requirements before it processes the main prompt.
  • Practical Guidance: You click to add items to this list, filling in static text or dynamic tokens for each example’s input, output, and associated file.
  • Use Case Context: You would use this field to show Claude exactly how a raw text paragraph should be transformed into a specific bulleted format.
  • Input: The example question or data provided to the AI.
  • Output: The perfect, expected response for that specific input.
  • File: An example file attachment associated with the training input.

8. Return Structure Object:

  • Purpose: Instructs zenphi to automatically force Claude to extract specific fields and return them as a neat, structured data object instead of a plain text paragraph.
  • Practical Guidance: Toggle this on statically if you want structured data without having to write complex JSON instructions in your prompt.
  • Use Case Context: You would enable “Return Structure Object” to guarantee Claude gives you separate “First Name” and “Last Name” fields that you can easily map to a CRM in the next step.

Fields:

  • Purpose: Defines the exact data points (objects or arrays) you want the AI to extract from the prompt or file.
  • Practical Guidance: You manually define these fields by adding them to the list and specifying their names and descriptions.
  • Use Case Context: You would add fields like “Invoice Number” and “Total Amount” so zenphi knows exactly what to ask Claude to extract.

9. Output as JSON:

  • Purpose: Forces the AI to return its final answer as raw, valid JSON text.
  • Practical Guidance: Toggle this on statically to enforce the format. While the toggle handles the JSON requirement, it is highly recommended to exactly outline your desired JSON structure or provide examples within your Prompt field so Claude knows exactly what keys and values to generate.
  • Use Case Context: You would use “Output as JSON” if you need to pass the AI’s response to a system that expects JSON formatting, or, more easily, to pass it into Zenphi’s Convert JSON to Object action so you can extract and use the data items one by one in subsequent flow steps.

10. Max Length:

  • Purpose: Sets a hard limit on how long the AI’s generated response can be, measured in tokens (where one token is roughly 4 characters).
  • Practical Guidance: Type a static number (e.g., 500) to ensure the response doesn’t get too long or consume too much of your API budget.
  • Use Case Context: You would use the “Max Length” field to restrict a generated summary to a short paragraph rather than a full-page essay.

11. Temperature:

  • Purpose: Controls how creative or predictable the AI’s response will be.
  • Practical Guidance: Enter a static number between 0 and 1. Use a low number (like 0.1) for strict, factual answers, and a higher number (like 0.8) for creative writing.
  • Use Case Context: You would set the “Temperature” to 0 when extracting financial data to ensure Claude doesn’t invent or hallucinate numbers.

12. Top P:

  • Purpose: Adjusts the probability threshold for token selection, offering another way to control the diversity of the AI’s vocabulary.
  • Practical Guidance: Enter a static decimal value. Like temperature, lower values make the output more focused and predictable, while higher values allow for more varied word choices.
  • Use Case Context: You would adjust “Top P” alongside temperature to fine-tune the exact creative flair of an AI-generated marketing email.

13. Enable Extended Thinking:

  • Purpose: Allows Claude to reason step-by-step internally before giving you the final answer, which drastically improves performance on complex logic or math problems.
  • Practical Guidance: Toggle this on statically. Note that it automatically sets the temperature to 1 and requires a compatible model (like Opus 4.x, Sonnet 4.x, or Haiku 4.5).
  • Use Case Context: You would enable “Extended Thinking” when asking Claude to solve a complex coding problem or analyze a dense legal contract.

Thinking Budget:

  • Purpose: Sets the maximum number of tokens Claude is allowed to spend on its internal “thinking” process.
  • Practical Guidance: Enter a static number that is at least 1024 but less than your “Max Length” setting.
  • Use Case Context: You would use the “Thinking Budget” to ensure Claude has enough processing room to solve a complex math equation before outputting the final number.

Outputs

1. Generated Output:

  • Data Description: The final text, summary, or extracted data produced by the Claude AI model in response to your prompt.
  • Workflow Utility: This is the core result of the action. You can pass this output into a Send Email action to forward an AI-generated response to a customer, or use it to update a Description field in a Salesforce CRM record.

2. Total Tokens:

  • Data Description: The combined sum of tokens consumed for both reading your input and generating the final response.
  • Workflow Utility: This number is highly useful for tracking API costs. You can log this value into a Google Sheet using an Add Row action to monitor how much your AI workflows are costing over time.

3. Input Tokens:

  • Purpose: The exact number of tokens Claude processed from your prompt and attached files. (Tokens are the unit Anthropic uses to bill your API account).
  • Workflow Utility: Mainly used for troubleshooting. If your flow acts weird, looking at this number in your Zenphi Run History tells you if you accidentally passed in a massive file that overloaded the AI, or if a file was corrupted/empty (which would show up as way fewer tokens than expected).

4. Output Tokens:

  • Purpose: The exact number of tokens Claude generated to form its answer.
  • Workflow Utility: Great for quality checks. If you asked Claude for a detailed, 3-page contract summary and your Run History shows it only generated 20 output tokens, you instantly know the AI gave a shortcut answer, threw an error message, or got cut off.

5. Model Name:

  • Data Description: The specific version of the Claude AI model that was used to execute the run.
  • Workflow Utility: This is useful for auditing and debugging. You can include this output in a Slack notification or log file so your team always knows which specific AI model generated a piece of content.

6. Thinking:

  • Data Description: The internal, step-by-step reasoning process Claude used before arriving at its final answer (only available if extended thinking was enabled).
  • Workflow Utility: This output is incredibly valuable for quality assurance. You can save this reasoning text to an internal database or append it as a private note in a Jira ticket, allowing human reviewers to see exactly how the AI arrived at its conclusion.

Example Use Cases

1. Extract Complex Document Data: Analyze dense files (such as legal contracts or technical .pdfs) passed from previous flow steps to automatically pull out specific clauses and structure the data for your databases or spreadsheets.

2. Generate Structured JSON Outputs: Process unstructured text inputs (like raw emails or web forms) and force Claude to return valid JSON. You can then easily use Zenphi’s Convert JSON to Object action to map those individual items into subsequent flow steps.

3. Automate Sophisticated Reasoning: Leverage Claude’s advanced logic to evaluate complex scenarios—such as reviewing incoming expense requests against company policy documents to automatically approve or flag them for human review.

4. Summarize Customer Communications: Read incoming emails and their attached files to generate concise, professional summaries, which can then be automatically routed to your support teams via Slack, Microsoft Teams, or saved directly into a CRM.

5. Train with Few-Shot Examples: Feed the action a dynamic collection of examples to teach Claude your exact business logic. This is perfect for teaching the AI exactly how to categorize support tickets, assign urgency levels, or format text in your company’s specific brand voice.

Example

Scenario

Your legal department frequently receives complex vendor contracts via email and spends hours manually reading them to extract key terms like the effective date, involved parties, and termination clauses. You need a way to automatically read these attached documents and extract the required information into a structured format so it can be logged directly into a database without human intervention.

Steps to Implement

1. Set the Trigger:

  • Action: Select the Email Arrival trigger to start the flow whenever a new contract is emailed to the legal department’s inbox.

2. Configure the Claude Text Agent Action:

  • Model: Select a capable model like Sonnet 4.6 from the dropdown to balance speed and high-level reasoning.
  • API Key: Insert your Anthropic API key dynamically using the token picker to pull it from a secure vault.
  • System Instructions: Type a static instruction such as, “You are an expert legal assistant specializing in contract analysis.”
  • Prompt: Type “Extract the key terms from the attached contract.”
  • Files: Use the token picker to map the file attachments directly from the Email Arrival trigger.
  • Return Structure Object: Toggle this on and click Fields to define specific fields (e.g., “Effective Date”, “Parties”, “Termination Clause”) to ensure the AI returns neatly categorized data points instead of a plain text paragraph.

3. Use the Output:

  • Action: Add a subsequent action to map the structured fields extracted by Claude directly into your CRM or database columns.

    Outcome

    The workflow now automatically intercepts incoming contracts, reads the attached files using advanced AI reasoning, and extracts the exact legal clauses required. This eliminates hours of manual document review, drastically reduces human error, and ensures your contract database is always up-to-date with perfectly structured data.

Best Practices

1. Secure Your API Key: Always store your Anthropic API key in a secure vault and pass it into the action dynamically using the token picker, rather than hardcoding it as plain text.

2. Monitor Token Usage: Utilize the “Total Tokens”, “Input Tokens”, and “Output Tokens” outputs to track your API consumption and log these values to a spreadsheet to keep your AI costs under control.

3. Leverage Structured Objects: Instead of writing complex prompt instructions to format the AI’s response, toggle on “Return Structure Object” to guarantee the output is perfectly formatted for downstream data mapping.

4. Optimize Extended Thinking: Only enable extended thinking for highly complex logic, math, or deep reasoning tasks, as it consumes a larger Thinking Budget and automatically sets the temperature to 1.

5. Control Creativity with Temperature: Set the “Temperature” to a low value (like 0.1) when extracting factual data from documents to prevent the AI from hallucinating, and reserve higher values (like 0.8) for creative text generation.