import { CodeTabs } from '../views/docs/CodeTabs';
import { Callout, AutoNextLink } from '../views/docs/prose';

export const SET_VOICEMAIL_ACTION_SIG_PY = `call.set_voicemail_action(
    hangup: bool = False,
    message: str | None = None,
)`;

export const SET_VOICEMAIL_ACTION_SIG_TS = `await call.setVoicemailAction(
  action: { hangup: true } | { message: string },
): Promise<void>`;

export const SET_VOICEMAIL_ACTION_EX_PY = `@agent.on_call_start
def on_call_start(call: guava.Call):
    call.set_voicemail_action(
        message="Hi, this is Alex from Bright Smile Dental. Please call us back at 555-0100 to confirm your appointment.",
    )`;

export const SET_VOICEMAIL_ACTION_EX_TS = `agent.onCallStart(async (call: guava.Call) => {
  await call.setVoicemailAction({
    message: "Hi, this is Alex from Bright Smile Dental. Please call us back at 555-0100 to confirm your appointment.",
  });
});`;

## set\_voicemail\_action()

`set_voicemail_action()` tells the agent what to do if it reaches an answering machine.

<Callout>
  <span className="text-primary font-semibold">Warning:</span> <code>set_voicemail_action()</code> and <code>reach_person()</code> both handle voicemail and <strong>cannot be used together</strong>. If you are using <code>reach_person()</code>, set voicemail behavior there via its <code>voicemail_message</code> or <code>voicemail_hangup</code> parameters instead. Using both raises an error.
</Callout>

<CodeTabs
  python={{ code: SET_VOICEMAIL_ACTION_SIG_PY, filename: "signature" }}
  typescript={{ code: SET_VOICEMAIL_ACTION_SIG_TS, filename: "signature" }}
/>

### Example

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

<Callout>
  <span className="text-primary font-semibold">Tip:</span> You must specify exactly one of <code>hangup</code> or <code>message</code> — passing both or neither raises an error.
</Callout>

<AutoNextLink currentSection="set-voicemail-action" />
