Skip to main content
POST
/
api
/
draft
/
talk
Talk to Draft
curl --request POST \
  --url https://api.example.com/api/draft/talk \
  --header 'Content-Type: application/json' \
  --data '
{
  "draft": "<string>",
  "instruction": "<string>",
  "messages": [
    {}
  ]
}
'
{
  "draft": "<string>",
  "error": "<string>"
}

Authentication

Requires a valid session. Returns 401 if unauthorized.

Overview

This endpoint uses Claude AI to revise an existing draft based on natural language instructions. It’s designed for iterative editing where users can say things like:
  • “Make it more friendly”
  • “Add information about our refund policy”
  • “Shorten this to 2 paragraphs”
  • “Make the tone more professional”
The AI preserves the core meaning and key information while applying your requested changes.

Request Body

draft
string
required
Current draft content in HTML format
instruction
string
required
Natural language instruction for how to revise the draft. Can be conversational.
messages
array
Email thread messages for additional context. The AI uses the customer’s last message to maintain relevance.Each message object contains:
  • body (string): Email body (HTML or plain text)

AI Processing

The endpoint:
  1. Strips HTML tags from the current draft to get plain text
  2. Extracts the customer’s last message for context
  3. Sends both to Claude with your instruction
  4. Returns the revised draft in HTML format
The AI is specifically prompted to:
  • Keep the same general meaning
  • Retain key information
  • Match the original language
  • Exclude signatures (managed separately)
  • Return valid HTML using semantic tags

Claude API Configuration

  • Model: claude-sonnet-4-6
  • Max Tokens: 1024
  • Role: User prompt with editing instructions

Response

draft
string
Revised draft in HTML format

Example Request

curl -X POST https://api.delightbridge.com/api/draft/talk \
  -H "Content-Type: application/json" \
  -H "Cookie: session=your-session-token" \
  -d '{
    "draft": "<p>Hi John,</p><p>Thank you for contacting us. Your refund request has been processed. It will take 5-7 business days to appear in your account.</p><p>Let me know if you have questions.</p>",
    "instruction": "Make it warmer and more empathetic. Also mention that we apologize for any inconvenience.",
    "messages": [
      {
        "body": "I need a refund for my recent purchase. This is very frustrating."
      }
    ]
  }'

Example Response

{
  "draft": "<p>Hi John,</p><p>I completely understand your frustration, and I sincerely apologize for any inconvenience this has caused. I want you to know that I've personally ensured your refund request has been processed.</p><p>You should see the refund in your account within 5-7 business days. I'll be monitoring this to make sure it goes through smoothly.</p><p>Please don't hesitate to reach out if you have any questions or concerns in the meantime. I'm here to help.</p>"
}

More Example Instructions

Make it shorter

{
  "instruction": "Condense this to just 2 sentences"
}

Add specific information

{
  "instruction": "Add a sentence explaining that we also sent a confirmation email"
}

Change tone

{
  "instruction": "Make this more professional and formal"
}

Fix issues

{
  "instruction": "Remove the part about the discount code since it's expired"
}

Multilingual editing

{
  "draft": "<p>안녕하세요,</p><p>주문하신 상품이 발송되었습니다.</p>",
  "instruction": "좀 더 친근하게 작성해줘"
}

Use Cases

Iterative Refinement

Users can repeatedly call this endpoint to refine a draft:
  1. Generate initial draft with /api/draft/generate
  2. “Make it shorter” → Get revised draft
  3. “Add more details about pricing” → Get refined draft
  4. “Make the tone friendlier” → Get final draft

Tone Adjustment

Quickly adjust the tone for different customers:
  • Professional for B2B
  • Casual for consumer products
  • Empathetic for support issues

Content Modification

Add or remove specific information without rewriting from scratch:
  • “Mention our 30-day guarantee”
  • “Remove the technical details”
  • “Add a discount code”

Error Responses

error
string
Error message describing what went wrong

401 Unauthorized

{
  "error": "Unauthorized"
}

500 Internal Server Error

{
  "error": "Failed to revise draft"
}
Common causes:
  • Claude API issues
  • Malformed HTML in draft
  • Network timeout
  • Invalid instruction format

Best Practices

  1. Clear Instructions: Be specific about what you want changed
  2. Context: Include the messages array for better AI understanding of customer sentiment
  3. Iterative: Use multiple small changes rather than one complex instruction
  4. Language: The AI automatically maintains the draft’s language
  5. HTML Structure: The API handles HTML cleanup automatically
  6. Preserve Signature: Signatures are managed separately and shouldn’t be included in the draft

Technical Notes

  • HTML tags are stripped before processing to ensure clean text analysis
  • The AI returns semantic HTML (<p>, <strong>, <em>, <ol>, <ul>, <li>, <a>)
  • Markdown code fences in Claude’s response are automatically removed
  • The customer’s last message is provided to maintain context and relevance

Build docs developers (and LLMs) love