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

# AI Generation

> Learn how Thread uses AI to generate personalized action drafts and handoff intelligence

## AI Overview

Thread uses OpenAI's GPT models to generate personalized content for emails, handoff Q\&A, forms, and more. AI drafts save CSMs hours while maintaining quality and personalization.

***

## What AI Generates

### Action Drafts

<CardGroup cols={2}>
  <Card title="Email Content" icon="envelope">
    Subject lines and email bodies with customer-specific details
  </Card>

  <Card title="Form Intro Text" icon="clipboard-list">
    Instructions and context for form collection
  </Card>

  <Card title="Slack Messages" icon="slack">
    Channel updates and notifications
  </Card>

  <Card title="Handoff Q&A" icon="handshake">
    Answers to handoff questions from CRM data
  </Card>
</CardGroup>

### What AI Doesn't Generate

<CardGroup cols={2}>
  <Card title="Form Fields" icon="input-text">
    Pre-configured in templates by admins
  </Card>

  <Card title="Document Types" icon="file">
    Pre-defined in action configuration
  </Card>

  <Card title="Meeting Agendas" icon="calendar">
    Template-based, not AI-generated (yet)
  </Card>

  <Card title="Portal UI" icon="browser">
    Configured through Thread's interfaces
  </Card>
</CardGroup>

***

## How AI Generation Works

### The AI Pipeline

<Steps>
  <Step title="Trigger Fires">
    Action trigger evaluates true (milestone starts + delay passes)
  </Step>

  <Step title="Context Gathering">
    Thread collects all relevant context:

    * Account data (company, contacts, ARR, close date)
    * Handoff Q\&A
    * Template configuration
    * Previous actions and responses
    * Milestone information
  </Step>

  <Step title="Prompt Construction">
    Thread builds a structured prompt with:

    * System instructions (tone, format, constraints)
    * Customer context
    * Action purpose and template
    * Variable placeholders
    * Output format requirements
  </Step>

  <Step title="OpenAI API Call">
    Thread sends prompt to OpenAI GPT-4

    * Uses structured output mode
    * Enforces JSON schema
    * Includes retry logic for failures
  </Step>

  <Step title="Response Processing">
    Thread processes AI response:

    * Validates format
    * Interpolates variables
    * Applies final formatting
    * Stores as draft
  </Step>

  <Step title="Ready for Review">
    Action moves to "ready" status in CSM Implementation Tab
  </Step>
</Steps>

***

## AI Context Sources

### Account Data

```typescript theme={null}
{
  company_name: "Acme Corporation",
  arr: 50000,
  close_date: "2024-03-15",
  primary_contact_name: "Jane Smith",
  primary_contact_email: "jane@acme.com",
  primary_contact_role: "IT Director",
  industry: "Healthcare",
  company_size: "51-500",
  notes: "Excited about API integrations..."
}
```

**What AI learns:**

* Company name for personalization
* Industry for relevant examples
* Contact name and role for appropriate tone
* ARR for understanding customer tier
* Notes for specific context

### Handoff Intelligence

```typescript theme={null}
{
  primary_use_case: "Sales outreach automation",
  top_goals: [
    "Reduce manual email work",
    "Improve response rates",
    "Scale team efficiency"
  ],
  risks: "Tight Q3 deadline, small IT team",
  stakeholders: "Jane (IT Director), Bob (Sales VP)",
  technical_environment: "Salesforce CRM, AWS infrastructure"
}
```

**What AI learns:**

* Why customer bought (use case)
* What success looks like (goals)
* Potential challenges (risks)
* Who's involved (stakeholders)
* Technical context (environment)

### Template Configuration

```typescript theme={null}
{
  action_type: "SEND_EMAIL",
  action_label: "Welcome Email",
  action_description: "Initial welcome and onboarding kickoff",
  milestone_name: "Kickoff",
  milestone_description: "Getting started with implementation",
  content_template: {
    subject: "Welcome to {{company_name}}'s onboarding!",
    body: "...template structure..."
  }
}
```

**What AI learns:**

* Purpose of this action
* Stage in customer journey
* Expected tone and format
* Required elements to include

### Previous Actions

```typescript theme={null}
{
  previous_emails: [
    {
      subject: "Welcome!",
      sent_at: "2024-03-15",
      customer_responded: true
    }
  ],
  customer_engagement: {
    portal_visits: 3,
    forms_completed: 1,
    documents_uploaded: 0
  }
}
```

**What AI learns:**

* Established relationship context
* What's been discussed already
* Customer engagement level
* Appropriate follow-up tone

***

## Prompt Engineering

### System Prompt

Thread uses a carefully crafted system prompt:

```
You are a Customer Success Manager writing to a new customer.

TONE:
- Professional yet friendly
- Enthusiastic but not overeager
- Helpful and supportive
- Clear and concise

REQUIREMENTS:
- Use customer's name and company name
- Reference specific details from their use case
- Include clear call-to-action
- Keep under 250 words
- Use bullet points for multiple items
- End with CSM signature

AVOID:
- Generic greetings ("Dear customer")
- Overly formal language
- Sales-y language
- Excessive exclamation marks
- Walls of text
```

### User Prompt (Context)

Then adds customer-specific context:

```
CUSTOMER: Acme Corporation
CONTACT: Jane Smith, IT Director
ARR: $50,000
INDUSTRY: Healthcare
USE CASE: Sales outreach automation
GOALS: Reduce manual work, improve response rates, scale efficiency
RISKS: Tight Q3 deadline, small IT team (3 people)

ACTION: Welcome Email - Initial kickoff
MILESTONE: Kickoff (Week 1)
PREVIOUS: None (first touchpoint)

Generate a welcome email that:
1. Welcomes Jane to the onboarding journey
2. References their sales automation use case
3. Sets expectations for timeline (mindful of Q3 deadline)
4. Offers support given their small team
5. Includes link to customer portal
6. Provides CSM contact info and calendar link
```

### Output Format

AI responds with structured JSON:

```json theme={null}
{
  "subject": "Welcome to Acme's Implementation, Jane!",
  "body": "Hi Jane,\n\nI'm excited to partner with Acme Corporation on your sales outreach automation journey!\n\n**What's Next:**\n- Review your portal timeline\n- Complete pre-kickoff questionnaire\n- Schedule our kickoff call\n\nGiven your Q3 deadline, we'll move efficiently while ensuring quality. I know your IT team is small, so I'll provide extra documentation and support.\n\n**Your Portal:** [link]\n**My Calendar:** [link]\n\nQuestions? I'm here to help.\n\nBest,\n{{csm_name}}"
}
```

***

## Regeneration

### When to Regenerate

<AccordionGroup>
  <Accordion title="Draft Misses the Mark">
    AI generated something generic or off-topic

    **Solution:** Regenerate with specific instructions
  </Accordion>

  <Accordion title="Wrong Tone">
    Too formal, too casual, or inconsistent with brand

    **Solution:** Regenerate with tone guidance
  </Accordion>

  <Accordion title="Missing Key Details">
    Didn't mention important context

    **Solution:** Regenerate with "Include \[specific detail]"
  </Accordion>

  <Accordion title="Too Long/Short">
    Doesn't match desired length

    **Solution:** Regenerate with length constraint
  </Accordion>
</AccordionGroup>

### How to Regenerate

1. Click "Regenerate" in action review
2. Add instructions in text field:
   * "Make it more casual"
   * "Add urgency about Q3 deadline"
   * "Focus on technical integration aspects"
   * "Keep under 150 words"
   * "Reference their Salesforce CRM specifically"
3. Click "Regenerate"
4. AI generates new draft with your guidance
5. Review new version

<Tip>
  Each regeneration is independent—AI doesn't remember previous attempts. Be specific about what you want changed!
</Tip>

***

## AI Quality Factors

### High-Quality Drafts

**When you get great drafts:**

* ✅ Rich customer data in account
* ✅ Detailed handoff Q\&A completed
* ✅ Clear action purpose in template
* ✅ Good content template with examples
* ✅ Relevant previous action context
* ✅ Specific, not generic account notes

**Example high-quality input:**

```
Company: Acme Corp
Contact: Jane Smith, IT Director
Use Case: Automating outbound sales emails for 50-person sales team
Goals: Reduce 10 hours/week of manual work, improve response rates from 15% to 25%
Risks: Tight Q3 deadline (July 1), small IT team may need extra support
Technical: Using Salesforce CRM, need API integration
Previous: Just signed contract, eager to get started
```

**Result:** Personalized, relevant, actionable email draft

### Lower-Quality Drafts

**When drafts are generic:**

* ❌ Minimal account data
* ❌ Skipped or sparse handoff
* ❌ Vague action descriptions
* ❌ Generic content templates
* ❌ No previous context
* ❌ Empty account notes

**Example low-quality input:**

```
Company: Acme Corp
Contact: Jane Smith
Use Case: [empty]
Goals: [empty]
Risks: [empty]
Technical: [empty]
Previous: [none]
```

**Result:** Generic "Dear Customer" email that needs heavy editing

<Warning>
  AI quality is directly proportional to input quality. Garbage in, garbage out!
</Warning>

***

## Improving AI Performance

### 1. Enrich Account Data

Before AI generates drafts:

<Tabs>
  <Tab title="During Account Creation">
    * Complete all optional fields
    * Add detailed notes
    * Include CRM data in raw payload
    * Paste relevant conversations
  </Tab>

  <Tab title="During Handoff">
    * AEs should enrich AI answers
    * Add context AI can't infer
    * Reference specific conversations
    * Highlight unique customer needs
  </Tab>

  <Tab title="Ongoing">
    * Update account notes regularly
    * Document customer preferences
    * Track engagement patterns
    * Note communication style
  </Tab>
</Tabs>

### 2. Optimize Templates

**Action descriptions:**

* ❌ "Send email"
* ✅ "Welcome email introducing CSM, setting expectations, and providing portal access"

**Content templates:**

* ❌ "Email customer about status"
* ✅ Structured template with sections, examples, and variables

**Context hints:**

* Add notes in template: "This email should reference the customer's use case and address any risks mentioned in handoff"

### 3. Provide Feedback

Help improve AI over time:

1. Note patterns in edits (always adding industry examples?)
2. Track which prompts work well
3. Share feedback with team
4. Request template improvements from admins

***

## AI Limitations

### What AI Can't Do

<CardGroup cols={2}>
  <Card title="Read Your Mind" icon="brain">
    AI doesn't know unstated customer preferences or internal politics
  </Card>

  <Card title="Remember Calls" icon="phone">
    AI doesn't have access to verbal conversations unless you document them
  </Card>

  <Card title="Predict Future" icon="crystal-ball">
    AI can't anticipate customer reactions or upcoming issues
  </Card>

  <Card title="Replace Human Touch" icon="heart">
    AI drafts need your personalization and relationship context
  </Card>
</CardGroup>

### When to Override AI

Always edit or rewrite when:

* Customer has unique situation not captured in data
* Sensitive topic requiring human nuance
* Relationship dynamic AI doesn't understand
* Brand voice needs adjustment
* Humor or empathy required
* Complex negotiation or escalation

<Info>
  Think of AI as your first draft writer, not your final copy editor. You're the expert—AI just saves you time on the initial structure.
</Info>

***

## Best Practices

<CardGroup cols={2}>
  <Card title="Always Review" icon="eye">
    Never execute AI drafts without reading them
  </Card>

  <Card title="Add Personal Touch" icon="user">
    Include customer-specific details only you know
  </Card>

  <Card title="Use Regeneration" icon="rotate">
    Don't settle for mediocre—guide AI to better output
  </Card>

  <Card title="Enrich Context" icon="database">
    Better input data = better AI output
  </Card>

  <Card title="Track Patterns" icon="chart-line">
    Note what works and share with team
  </Card>

  <Card title="Provide Feedback" icon="comment">
    Help improve prompts and templates over time
  </Card>
</CardGroup>

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Action Execution" icon="bolt" href="/csm-guide/automation/action-execution">
    Learn the full action execution workflow
  </Card>

  <Card title="Implementation Tab" icon="tasks" href="/csm-guide/accounts/implementation-tab">
    Master action review and editing
  </Card>

  <Card title="Handoff Process" icon="handshake" href="/csm-guide/accounts/handoff-process">
    Understand how handoff enriches AI context
  </Card>

  <Card title="Best Practices" icon="star" href="/csm-guide/templates/best-practices">
    Design templates that enable great AI output
  </Card>
</CardGroup>
