npm package: @sharpapi/sharpapi-node-thank-you-email
Description: SharpAPI.com Node.js SDK for generating thank you emails
Author: Dawid Makowski
Latest version: 1.0.1

![SharpAPI GitHub cover](https://sharpapi.com/sharpapi-github-php-bg.jpg "SharpAPI Node.js Client")

# Thank You Email Generator API for Node.js

## 💌 Generate personalized thank you emails — powered by SharpAPI AI.

[![npm version](https://img.shields.io/npm/v/@sharpapi/sharpapi-node-thank-you-email.svg)](https://www.npmjs.com/package/@sharpapi/sharpapi-node-thank-you-email)
[![License](https://img.shields.io/npm/l/@sharpapi/sharpapi-node-thank-you-email.svg)](https://github.com/sharpapi/sharpapi-node-client/blob/master/LICENSE.md)

**SharpAPI Thank You Email Generator** creates personalized, professional thank you emails for e-commerce transactions. Perfect for order confirmations, customer appreciation, and post-purchase communication.

---

## 📋 Table of Contents

1. [Requirements](#requirements)
2. [Installation](#installation)
3. [Usage](#usage)
4. [API Documentation](#api-documentation)
5. [Examples](#examples)
6. [License](#license)

---

## Requirements

- Node.js >= 16.x
- npm or yarn

---

## Installation

### Step 1. Install the package via npm:

```bash
npm install @sharpapi/sharpapi-node-thank-you-email
```

### Step 2. Get your API key

Visit [SharpAPI.com](https://sharpapi.com/) to get your API key.

---

## Usage

```javascript
const { SharpApiThankYouEmailService } = require('@sharpapi/sharpapi-node-thank-you-email');

const apiKey = process.env.SHARP_API_KEY; // Store your API key in environment variables
const service = new SharpApiThankYouEmailService(apiKey);

const orderData = {
  customerName: 'John Doe',
  productName: 'Wireless Headphones',
  orderNumber: 'ORD-12345'
};

async function generateThankYou() {
  try {
    // Submit email generation job
    const statusUrl = await service.generateThankYouEmail(
      orderData.customerName,
      orderData.productName,
      orderData.orderNumber
    );
    console.log('Job submitted. Status URL:', statusUrl);

    // Fetch results (polls automatically until complete)
    const result = await service.fetchResults(statusUrl);
    console.log('Generated email:', result.getResultJson());
  } catch (error) {
    console.error('Error:', error.message);
  }
}

generateThankYou();
```

---

## API Documentation

### Methods

#### `generateThankYouEmail(customerName: string, productName: string, orderNumber?: string, voiceTone?: string): Promise<string>`

Generates a personalized thank you email.

**Parameters:**
- `customerName` (string, required): Customer's name
- `productName` (string, required): Product or service purchased
- `orderNumber` (string, optional): Order reference number
- `voiceTone` (string, optional): Tone of the email ('Professional', 'Friendly', 'Enthusiastic')

**Returns:**
- Promise<string>: Status URL for polling the job result

**Example:**
```javascript
const statusUrl = await service.generateThankYouEmail(
  'Sarah Johnson',
  'Premium Yoga Mat',
  'ORD-67890',
  'Friendly'
);
const result = await service.fetchResults(statusUrl);
```

### Response Format

The API returns a professionally crafted thank you email:

```json
{
  "email": "Thank you, John! We hope you enjoy your new Wireless Headphones. They're designed to deliver exceptional sound quality and comfort for all-day listening. If you have any questions or need support, we're here to help. Thanks for choosing us!",
  "subject": "Thank You for Your Order #ORD-12345",
  "tone": "Friendly"
}
```

---

## Examples

### Basic Thank You Email

```javascript
const { SharpApiThankYouEmailService } = require('@sharpapi/sharpapi-node-thank-you-email');

const service = new SharpApiThankYouEmailService(process.env.SHARP_API_KEY);

service.generateThankYouEmail(
  'Emma Wilson',
  'Organic Coffee Beans',
  'ORD-11223'
)
  .then(statusUrl => service.fetchResults(statusUrl))
  .then(result => {
    const email = result.getResultJson();
    console.log('📧 Subject:', email.subject);
    console.log('📝 Body:', email.email);
  })
  .catch(error => console.error('Generation failed:', error));
```

### Tone-Specific Email

```javascript
const service = new SharpApiThankYouEmailService(process.env.SHARP_API_KEY);

const statusUrl = await service.generateThankYouEmail(
  'Michael Chen',
  'Professional Camera Lens',
  'ORD-55789',
  'Professional'
);

const result = await service.fetchResults(statusUrl);
const email = result.getResultJson();

console.log('Professional thank you email:');
console.log(email.email);
```

### Automated Post-Purchase Workflow

```javascript
const service = new SharpApiThankYouEmailService(process.env.SHARP_API_KEY);

async function sendThankYouEmail(order) {
  // Generate personalized email
  const statusUrl = await service.generateThankYouEmail(
    order.customerName,
    order.productName,
    order.orderNumber,
    'Enthusiastic'
  );

  const result = await service.fetchResults(statusUrl);
  const emailContent = result.getResultJson();

  // In real implementation, integrate with email service
  return {
    to: order.customerEmail,
    subject: emailContent.subject,
    body: emailContent.email,
    orderRef: order.orderNumber
  };
}

const completedOrder = {
  orderNumber: 'ORD-99888',
  customerName: 'Lisa Brown',
  customerEmail: 'lisa@example.com',
  productName: 'Smart Fitness Watch'
};

const emailToSend = await sendThankYouEmail(completedOrder);
console.log('Email ready to send:', emailToSend);
```

### Batch Email Generation

```javascript
const service = new SharpApiThankYouEmailService(process.env.SHARP_API_KEY);

const orders = [
  { customerName: 'Alice Green', product: 'Yoga Mat', orderId: 'ORD-001' },
  { customerName: 'Bob Smith', product: 'Water Bottle', orderId: 'ORD-002' },
  { customerName: 'Carol White', product: 'Running Shoes', orderId: 'ORD-003' }
];

const thankYouEmails = await Promise.all(
  orders.map(async (order) => {
    const statusUrl = await service.generateThankYouEmail(
      order.customerName,
      order.product,
      order.orderId,
      'Friendly'
    );
    const result = await service.fetchResults(statusUrl);
    return {
      orderId: order.orderId,
      email: result.getResultJson()
    };
  })
);

console.log(`Generated ${thankYouEmails.length} thank you emails`);
```

---

## Use Cases

- **Order Confirmations**: Send personalized thank you after purchase
- **Service Subscriptions**: Thank customers for signing up
- **Event Registrations**: Acknowledge event sign-ups
- **Donation Receipts**: Thank donors for contributions
- **Trial Sign-ups**: Welcome new trial users
- **Membership Renewals**: Thank customers for renewing
- **Customer Appreciation**: Build relationships with personalized messages

---

## Voice Tones

Choose the appropriate tone for your brand:

- **Professional**: Formal, business-appropriate language
- **Friendly**: Warm, casual, conversational
- **Enthusiastic**: Energetic, exciting, motivational
- **Grateful**: Emphasizes appreciation and gratitude
- **Luxury**: Sophisticated, premium, exclusive

---

## Personalization Features

Each email includes:

- **Customer's name**: Personal address
- **Product reference**: Specific item purchased
- **Order number**: Transaction reference
- **Brand voice**: Consistent with your tone choice
- **Call-to-action**: Subtle engagement prompt
- **Support offer**: Invitation to reach out

---

## API Endpoint

**POST** `/ecommerce/thank_you_email`

For detailed API specifications, refer to:
- [Postman Documentation](https://documenter.getpostman.com/view/31106842/2sBXVeGsVo)
- [Product Page](https://sharpapi.com/en/catalog/ai/e-commerce/custom-thank-you-e-mail-generator)

---

## Related Packages

- [@sharpapi/sharpapi-node-product-intro](https://www.npmjs.com/package/@sharpapi/sharpapi-node-product-intro) - Product introductions
- [@sharpapi/sharpapi-node-product-review-sentiment](https://www.npmjs.com/package/@sharpapi/sharpapi-node-product-review-sentiment) - Review sentiment
- [@sharpapi/sharpapi-node-paraphrase](https://www.npmjs.com/package/@sharpapi/sharpapi-node-paraphrase) - Text paraphrasing
- [@sharpapi/sharpapi-node-client](https://www.npmjs.com/package/@sharpapi/sharpapi-node-client) - Full SharpAPI SDK

---

## License

This project is licensed under the MIT License. See the [LICENSE.md](LICENSE.md) file for details.

---

## Support

- **Documentation**: [SharpAPI.com Documentation](https://sharpapi.com/documentation)
- **Issues**: [GitHub Issues](https://github.com/sharpapi/sharpapi-node-client/issues)
- **Email**: contact@sharpapi.com

---

**Powered by [SharpAPI](https://sharpapi.com/) - AI-Powered API Workflow Automation**