import { CodeTabs } from '../views/docs/CodeTabs';
import { Callout, NextLink } from '../views/docs/prose';
export const READ_SCRIPT_SIG_PY = `def read_script(script: str)`;

export const READ_SCRIPT_SIG_TS = `readScript(script: string): Promise<void>`;

export const READ_SCRIPT_EX_PY = `@agent.on_call_start
def on_call_start(call: guava.Call):
    call.read_script(
        "Hello! This is a courtesy call from Bright Smile Dental. "
        "We're confirming your appointment tomorrow at 2 PM."
    )
    call.set_task(
        "confirm_appointment",
        checklist=[
            guava.Field(key="confirmed", field_type="text",
                        description="Did they confirm the appointment?"),
        ],
    )

@agent.on_task_complete("confirm_appointment")
def on_confirmed(call: guava.Call):
    call.hangup()`;

export const READ_SCRIPT_EX_TS = `agent.onCallStart(async (call: guava.Call) => {
  await call.readScript(
    "Hello! This is a courtesy call from Bright Smile Dental. "
    + "We're confirming your appointment tomorrow at 2 PM."
  );
  await call.setTask({
    taskId: "confirm_appointment",
    checklist: [
      guava.Field({
        key: "confirmed",
        fieldType: "text",
        description: "Did they confirm the appointment?",
      }),
    ],
  });
});

agent.onTaskComplete("confirm_appointment", async (call) => {
  await call.hangup();
})`;

## read\_script()

`read_script()` speaks a verbatim opening statement at the very start of a call, before any LLM involvement. Use it for compliance disclosures, scripted greetings, or anything that must be delivered word-for-word.

<CodeTabs
  python={{ code: READ_SCRIPT_SIG_PY, filename: "signature" }}
  typescript={{ code: READ_SCRIPT_SIG_TS, filename: "signature" }}
/>

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

<Callout>
  <span className="text-primary font-semibold">Note:</span> Unlike `Say` in a checklist, `read_script()` fires before any LLM turn and before any task is set. It's the agent's very first words.
</Callout>

<NextLink section="get-field" label="get_field()" />
