> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ringg.ai/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> To search or read these docs, connect the Ringg docs MCP server at https://docs.ringg.ai/mcp (no key needed; tools search_ringg_ai and query_docs_filesystem_ringg_ai) instead of browsing pages one by one. Setup for each client: https://docs.ringg.ai/resources/mcp-server/docs-mcp-server/mcp-for-ai-assistants.md
> The dashboard labels agents "Assistants"; these docs say "agent". Both mean the same object, identified by agent_id.
> API base URL: https://prod-api.ringg.ai/ca/api/v0. Send the workspace API key in the X-API-KEY header, from server-side code only.
> Placing a call dials a real phone number and spends credits. Confirm the number with the user before calling.
> To act on a Ringg workspace (place calls, edit agents, read transcripts), use the separate Ringg workspace MCP server at https://mcp.ringg.ai/mcp: https://docs.ringg.ai/resources/mcp-server/workspace-mcp-server/overview.md

# Lesson: Advanced Analysis

> Define payment_promised, promised_date and objection as Advanced Analysis variables on the EMI reminder agent, mark the goal, and test them on a past call.

export const Quiz = ({question, answers, correctFeedback, incorrectFeedback}) => {
  const [selected, setSelected] = React.useState(null);
  const [checked, setChecked] = React.useState(false);
  const quizId = React.useId();
  const isCorrect = checked && answers[selected]?.correct;
  const reset = () => {
    setSelected(null);
    setChecked(false);
  };
  const optionStyle = (answer, i) => {
    const base = {
      display: "flex",
      alignItems: "flex-start",
      gap: "0.6rem",
      padding: "0.6rem 0.8rem",
      marginTop: "0.5rem",
      borderRadius: "0.6rem",
      border: "1px solid rgba(128, 128, 128, 0.35)",
      cursor: checked ? "default" : "pointer",
      lineHeight: 1.45
    };
    if (checked && answer.correct) {
      return {
        ...base,
        borderColor: "rgba(22, 163, 74, 0.8)",
        background: "rgba(22, 163, 74, 0.12)"
      };
    }
    if (checked && selected === i && !answer.correct) {
      return {
        ...base,
        borderColor: "rgba(220, 38, 38, 0.8)",
        background: "rgba(220, 38, 38, 0.1)"
      };
    }
    if (!checked && selected === i) {
      return {
        ...base,
        borderColor: "currentColor",
        background: "rgba(128, 128, 128, 0.12)"
      };
    }
    return base;
  };
  const buttonStyle = disabled => ({
    marginTop: "0.9rem",
    padding: "0.45rem 0.9rem",
    borderRadius: "0.5rem",
    border: "1px solid rgba(128, 128, 128, 0.5)",
    background: "rgba(128, 128, 128, 0.1)",
    color: "inherit",
    font: "inherit",
    fontSize: "0.9em",
    cursor: disabled ? "not-allowed" : "pointer",
    opacity: disabled ? 0.5 : 1
  });
  return <div style={{
    marginTop: "1.5rem",
    padding: "1rem 1.1rem",
    borderRadius: "0.8rem",
    border: "1px solid rgba(128, 128, 128, 0.35)"
  }}>
      <Badge color="green">Quiz</Badge>
      <p id={quizId + "-question"} style={{
    fontWeight: 600,
    margin: "0.6rem 0 0.2rem"
  }}>
        {question}
      </p>
      <div role="radiogroup" aria-labelledby={quizId + "-question"} aria-disabled={checked}>
        {answers.map((answer, i) => <label key={i} style={optionStyle(answer, i)}>
            <input type="radio" name={"quiz-" + quizId} checked={selected === i} onChange={() => !checked && setSelected(i)} disabled={checked} style={{
    marginTop: "0.3rem",
    flexShrink: 0
  }} />
            <span>{answer.text}</span>
          </label>)}
      </div>
      {checked && <div role="status" aria-live="polite" aria-atomic="true" style={{
    marginTop: "0.9rem",
    padding: "0.7rem 0.9rem",
    borderRadius: "0.6rem",
    lineHeight: 1.5,
    background: isCorrect ? "rgba(22, 163, 74, 0.12)" : "rgba(220, 38, 38, 0.1)"
  }}>
          <strong style={{
    marginRight: "0.4rem"
  }}>{isCorrect ? "✓" : "✗"}</strong>
          {isCorrect ? correctFeedback : incorrectFeedback}
        </div>}
      {!checked ? <button type="button" onClick={() => selected !== null && setChecked(true)} disabled={selected === null} style={buttonStyle(selected === null)}>
          Check answer
        </button> : <button type="button" onClick={reset} style={buttonStyle(false)}>
          Try again
        </button>}
    </div>;
};

export const RelatedTopics = ({items}) => <div className="not-prose mt-12">
    <div className="text-sm font-medium text-gray-500 dark:text-zinc-400 mb-3">Related topics</div>
    <div className="flex flex-col gap-2.5">
      {items.map(([title, href]) => <a key={href} href={href} className="flex items-center gap-2.5 text-sm text-gray-700 hover:text-gray-950 dark:text-zinc-300 dark:hover:text-white">
          <Icon icon="file-text" size={16} color="currentColor" />
          {title}
        </a>)}
    </div>
  </div>;

**Part 3: Making your agent smarter · Lesson 4 of 4 · 15 minutes**

## Objective

Define the three facts Acme wants from every reminder call as typed Advanced Analysis variables, mark the goal, and test them on a call you already made.

## The scenario

After the call, Acme's collections team needs three things: did the customer promise to pay, by which date, and if not, why. Status, duration and transcript are already in Logs; these three are extracted from the transcript by Advanced Analysis after every conversation. `payment_promised` is the goal, so Analytics can report a success rate in part 6.

## Hands-on

<Frame caption="Adding a Boolean goal variable and testing it on a past call">
  <video alt="Adding a Boolean goal variable and testing it on a past call" aria-label="Adding a Boolean goal variable and testing it on a past call" controls muted playsInline className="w-full rounded-xl" style={{ aspectRatio: "16 / 10" }} preload="metadata" controlsList="nodownload noremoteplayback" poster="/media/agents-advanced-analysis/poster.webp">
    <source src="https://mintcdn.com/ringgai-0da73d20/zhzhS2waLZvF8qXk/media/agents-advanced-analysis/video.webm?fit=max&auto=format&n=zhzhS2waLZvF8qXk&q=85&s=6e81dc121edb1604ff8c99b7453059e1" type="video/webm; codecs=&#x22;av01.0.09M.08&#x22;" data-path="media/agents-advanced-analysis/video.webm" />
  </video>
</Frame>

<Steps>
  <Step title="Open Advanced Analysis">
    In Ananya's editor, open **Advanced Settings → Advanced Analysis** and click **Add a new variable**. The **Add variables** dialog opens.
  </Step>

  <Step title="Add the goal">
    Set **Variable name** to `payment_promised` and keep **Type** on **Boolean**. For **Description**, write the instruction "True if the customer agreed to pay by a specific date." Set **Default value** to `false` and switch on **Use as goal**.
  </Step>

  <Step title="Add the other two">
    Click **Add new variable** inside the dialog for each:

    * `promised_date`, type **Date**, description "The date the customer promised to pay, if any."
    * `objection`, type **Enum**, with the options `already_paid`, `no_money`, `dispute` and `none` (type each and press Enter), description "The customer's main reason for not paying.", default value `none`.

    The button at the bottom now reads **Add 3**. Click it.
  </Step>

  <Step title="Add context and tool logs">
    Below the table, write in **Context** what counts as a promise: "A promise means the customer named a date, or said they would pay today." Click **Save**: "Context saved". Switch on **Log tool calls** so the analysis also sees what `crm_lookup` returned.
  </Step>

  <Step title="Test on your part 2 call">
    Click **Test**. In **Test advanced analysis**, pick the test call from part 2 under **Or select from recent call log**; picking it runs the test straight away. **Analysis result** appears next to **Call transcript**.
  </Step>
</Steps>

<Frame caption="Variables after saving">
  <img src="https://mintcdn.com/ringgai-0da73d20/zhzhS2waLZvF8qXk/media/agents-advanced-analysis/variables.webp?fit=max&auto=format&n=zhzhS2waLZvF8qXk&q=85&s=a0b603608a3612c8d785fa07b96e1196" alt="Advanced analysis table listing promised_date (Date), objection (Enum, default none), payment_promised (Boolean, default false) with a Goal chip, and amount_promised (Number)" width="2236" height="640" data-path="media/agents-advanced-analysis/variables.webp" />
</Frame>

## Checkpoint

<Check>
  The table lists the three variables with their **Type** and **Default value**, and `payment_promised` carries a **Goal** chip. In the test, **Analysis result** shows a value for each that matches what you said on the call: if you named a date, `payment_promised` is true and `promised_date` holds it.
</Check>

## Exercise

Add `amount_promised` as a **Number** with the description "The amount in rupees the customer said they would pay." and the default value `0`, then click **Test** on the same call. Expected result: a fourth row in the table and a fourth line in **Analysis result**, reading `0` if you named no amount on the call.

## What you learned

* Advanced Analysis variables are filled from the transcript after the call; custom variables are filled before it. They are separate lists.
* Only a Boolean can be the goal, and an agent has one at a time. Analytics' **Goal achieved** comes from it.
* Results appear in the call's **Advanced analysis** tab in Logs, in Logs filters, Analytics cohorts, post-call tools, alerts and the `client_analysis_completed` webhook, which the capstone uses to hand them to the CRM.

<Quiz
  question="Acme wants Analytics to report a success rate, so you mark promised_date (type Date) as the goal. What happens?"
  answers={[
{ text: "It works; any variable can be the goal", correct: false },
{ text: "It cannot be the goal: only a Boolean can, and an agent has one at a time", correct: true },
{ text: "It works, but only after Log tool calls is on", correct: false },
{ text: "It becomes the goal and payment_promised is deleted", correct: false },
]}
  correctFeedback="Right. Only a Boolean can be the goal, and an agent has one goal at a time. Analytics' Goal achieved is the share of analysed calls where that Boolean came back true, which is why payment_promised carries the Goal chip."
  incorrectFeedback="Not quite. The goal must be a Boolean, and there is one per agent. Goal achieved in Analytics is computed from it. A Date, Enum or Number can be extracted and filtered on, but not marked as the goal."
/>

<RelatedTopics items={[["Advanced Analysis", "/documentation/build-agents/customize-agent-behaviour/advanced-analysis"], ["Logs", "/documentation/monitor/logs#custom-variables-and-advanced-analysis"]]} />


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.