import { CodeBlock } from '../views/docs/CodeBlock';
import { Callout, Prose, NextLink } from '../views/docs/prose';
import { AGENTIC_TENACITY_EX } from './guides-constants';

## Agentic Tenacity

Agentic Tenacity is an extension to Guavadialer that intelligently reaches out to contacts across multiple channels before calling them. Rather than placing blind cold calls, the system warms contacts with pre-call alerts and responds to inbound messages to reschedule, answer questions, or mark contacts as do-not-call.

<Callout>
  <span className="text-primary font-semibold">Current status:</span> SMS is the only supported outreach modality. Email, WhatsApp, and RCS/iMessage support is planned. Only pre-call messages are supported — post-call follow-ups are not yet implemented.
</Callout>

### How it works

When you upload contacts with outreach modalities enabled, Guava sends a pre-call message before each call attempt. For example: "Hi! This is a message from Harper Valley. We are doing a political opinion survey, and you should receive a call from us in the next 10–30 minutes. If that is not a good time, please reply with a time that works better for you."

The system automatically handles inbound replies — rescheduling calls, answering general questions about the campaign, or marking contacts as DNC.

### Setup

<Prose><span className="text-foreground">1. Apply for SMS permissions</span> — contact the Guava team to enable SMS for your account. This is currently a manual process via a Google Form.</Prose>

<Prose><span className="text-foreground">2. Provide a campaign description</span> — the `description` parameter in `get_or_create_campaign()` is required when using Agentic Tenacity. The agent uses it to respond to messages about who is calling and what the campaign is about.</Prose>

### Setting outreach modalities

Modalities can be set in two places. Per-contact settings take priority over global settings.

<Prose><span className="text-foreground">Per contact:</span> Add an `outreach_modalities` field to individual contact objects. This controls which modalities are used for that specific contact.</Prose>

<Prose><span className="text-foreground">Global shortcut:</span> Pass `outreach_modalities` to `campaign.upload_contacts()` to apply the same modalities to all contacts in that batch (unless a contact has its own setting).</Prose>

If neither is set, no pre-call messages are sent and the campaign behaves as a standard Guavadialer campaign.

### Example

<CodeBlock code={AGENTIC_TENACITY_EX} filename="agentic_campaign.py" language="python" />

<NextLink section="deployment" label="Deployment" />
