import { CodeTabs } from '../views/docs/CodeTabs';
import { Callout, NextLink } from '../views/docs/prose';
import {
  GET_FIELD_SIG_PY, GET_FIELD_SIG_TS,
  GET_FIELD_EX_PY, GET_FIELD_EX_TS,
} from './sdk-reference-constants';

## get_field()

After the checklist completes and `agent.on_task_complete` fires, use `call.get_field()` to retrieve collected values by their key. This is where you write results to your CRM, database, or EHR.

<CodeTabs
  python={{ code: GET_FIELD_SIG_PY, filename: "signature" }}
  typescript={{ code: GET_FIELD_SIG_TS, filename: "signature" }}
/>

<CodeTabs
  python={{ code: GET_FIELD_EX_PY, filename: "example.py" }}
  typescript={{ code: GET_FIELD_EX_TS, filename: "example.ts" }}
/>

### Return types by field type

The type of the value returned by `get_field()` depends on the field's `field_type`:

| `field_type` | Returned value |
|---|---|
| `text` | `str` |
| `date` | `dict` with keys `year`, `month`, `day` (all `int`) |
| `integer` | `int` |
| `multiple_choice` | `str` (guaranteed to be one of the values in `choices` or returned by `choice_generator`) |
| `calendar_slot` | ISO-8601 datetime string (e.g. `"2022-12-25T16:30"`) |

<Callout>
  <span className="text-primary font-semibold">Tip:</span> You can call `get_field()` at any point after the field has been collected — not just in `on_task_complete`. Use it in mid-call callbacks to personalize subsequent steps.
</Callout>

<NextLink section="intent-recognizer" label="IntentRecognizer" />
