@sharpapi/sharpapi-node-thank-you-email 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,306 @@
1
+ ![SharpAPI GitHub cover](https://sharpapi.com/sharpapi-github-php-bg.jpg "SharpAPI Node.js Client")
2
+
3
+ # Thank You Email Generator API for Node.js
4
+
5
+ ## 💌 Generate personalized thank you emails — powered by SharpAPI AI.
6
+
7
+ [![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)
8
+ [![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)
9
+
10
+ **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.
11
+
12
+ ---
13
+
14
+ ## 📋 Table of Contents
15
+
16
+ 1. [Requirements](#requirements)
17
+ 2. [Installation](#installation)
18
+ 3. [Usage](#usage)
19
+ 4. [API Documentation](#api-documentation)
20
+ 5. [Examples](#examples)
21
+ 6. [License](#license)
22
+
23
+ ---
24
+
25
+ ## Requirements
26
+
27
+ - Node.js >= 16.x
28
+ - npm or yarn
29
+
30
+ ---
31
+
32
+ ## Installation
33
+
34
+ ### Step 1. Install the package via npm:
35
+
36
+ ```bash
37
+ npm install @sharpapi/sharpapi-node-thank-you-email
38
+ ```
39
+
40
+ ### Step 2. Get your API key
41
+
42
+ Visit [SharpAPI.com](https://sharpapi.com/) to get your API key.
43
+
44
+ ---
45
+
46
+ ## Usage
47
+
48
+ ```javascript
49
+ const { SharpApiThankYouEmailService } = require('@sharpapi/sharpapi-node-thank-you-email');
50
+
51
+ const apiKey = process.env.SHARP_API_KEY; // Store your API key in environment variables
52
+ const service = new SharpApiThankYouEmailService(apiKey);
53
+
54
+ const orderData = {
55
+ customerName: 'John Doe',
56
+ productName: 'Wireless Headphones',
57
+ orderNumber: 'ORD-12345'
58
+ };
59
+
60
+ async function generateThankYou() {
61
+ try {
62
+ // Submit email generation job
63
+ const statusUrl = await service.generateThankYouEmail(
64
+ orderData.customerName,
65
+ orderData.productName,
66
+ orderData.orderNumber
67
+ );
68
+ console.log('Job submitted. Status URL:', statusUrl);
69
+
70
+ // Fetch results (polls automatically until complete)
71
+ const result = await service.fetchResults(statusUrl);
72
+ console.log('Generated email:', result.getResultJson());
73
+ } catch (error) {
74
+ console.error('Error:', error.message);
75
+ }
76
+ }
77
+
78
+ generateThankYou();
79
+ ```
80
+
81
+ ---
82
+
83
+ ## API Documentation
84
+
85
+ ### Methods
86
+
87
+ #### `generateThankYouEmail(customerName: string, productName: string, orderNumber?: string, voiceTone?: string): Promise<string>`
88
+
89
+ Generates a personalized thank you email.
90
+
91
+ **Parameters:**
92
+ - `customerName` (string, required): Customer's name
93
+ - `productName` (string, required): Product or service purchased
94
+ - `orderNumber` (string, optional): Order reference number
95
+ - `voiceTone` (string, optional): Tone of the email ('Professional', 'Friendly', 'Enthusiastic')
96
+
97
+ **Returns:**
98
+ - Promise<string>: Status URL for polling the job result
99
+
100
+ **Example:**
101
+ ```javascript
102
+ const statusUrl = await service.generateThankYouEmail(
103
+ 'Sarah Johnson',
104
+ 'Premium Yoga Mat',
105
+ 'ORD-67890',
106
+ 'Friendly'
107
+ );
108
+ const result = await service.fetchResults(statusUrl);
109
+ ```
110
+
111
+ ### Response Format
112
+
113
+ The API returns a professionally crafted thank you email:
114
+
115
+ ```json
116
+ {
117
+ "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!",
118
+ "subject": "Thank You for Your Order #ORD-12345",
119
+ "tone": "Friendly"
120
+ }
121
+ ```
122
+
123
+ ---
124
+
125
+ ## Examples
126
+
127
+ ### Basic Thank You Email
128
+
129
+ ```javascript
130
+ const { SharpApiThankYouEmailService } = require('@sharpapi/sharpapi-node-thank-you-email');
131
+
132
+ const service = new SharpApiThankYouEmailService(process.env.SHARP_API_KEY);
133
+
134
+ service.generateThankYouEmail(
135
+ 'Emma Wilson',
136
+ 'Organic Coffee Beans',
137
+ 'ORD-11223'
138
+ )
139
+ .then(statusUrl => service.fetchResults(statusUrl))
140
+ .then(result => {
141
+ const email = result.getResultJson();
142
+ console.log('📧 Subject:', email.subject);
143
+ console.log('📝 Body:', email.email);
144
+ })
145
+ .catch(error => console.error('Generation failed:', error));
146
+ ```
147
+
148
+ ### Tone-Specific Email
149
+
150
+ ```javascript
151
+ const service = new SharpApiThankYouEmailService(process.env.SHARP_API_KEY);
152
+
153
+ const statusUrl = await service.generateThankYouEmail(
154
+ 'Michael Chen',
155
+ 'Professional Camera Lens',
156
+ 'ORD-55789',
157
+ 'Professional'
158
+ );
159
+
160
+ const result = await service.fetchResults(statusUrl);
161
+ const email = result.getResultJson();
162
+
163
+ console.log('Professional thank you email:');
164
+ console.log(email.email);
165
+ ```
166
+
167
+ ### Automated Post-Purchase Workflow
168
+
169
+ ```javascript
170
+ const service = new SharpApiThankYouEmailService(process.env.SHARP_API_KEY);
171
+
172
+ async function sendThankYouEmail(order) {
173
+ // Generate personalized email
174
+ const statusUrl = await service.generateThankYouEmail(
175
+ order.customerName,
176
+ order.productName,
177
+ order.orderNumber,
178
+ 'Enthusiastic'
179
+ );
180
+
181
+ const result = await service.fetchResults(statusUrl);
182
+ const emailContent = result.getResultJson();
183
+
184
+ // In real implementation, integrate with email service
185
+ return {
186
+ to: order.customerEmail,
187
+ subject: emailContent.subject,
188
+ body: emailContent.email,
189
+ orderRef: order.orderNumber
190
+ };
191
+ }
192
+
193
+ const completedOrder = {
194
+ orderNumber: 'ORD-99888',
195
+ customerName: 'Lisa Brown',
196
+ customerEmail: 'lisa@example.com',
197
+ productName: 'Smart Fitness Watch'
198
+ };
199
+
200
+ const emailToSend = await sendThankYouEmail(completedOrder);
201
+ console.log('Email ready to send:', emailToSend);
202
+ ```
203
+
204
+ ### Batch Email Generation
205
+
206
+ ```javascript
207
+ const service = new SharpApiThankYouEmailService(process.env.SHARP_API_KEY);
208
+
209
+ const orders = [
210
+ { customerName: 'Alice Green', product: 'Yoga Mat', orderId: 'ORD-001' },
211
+ { customerName: 'Bob Smith', product: 'Water Bottle', orderId: 'ORD-002' },
212
+ { customerName: 'Carol White', product: 'Running Shoes', orderId: 'ORD-003' }
213
+ ];
214
+
215
+ const thankYouEmails = await Promise.all(
216
+ orders.map(async (order) => {
217
+ const statusUrl = await service.generateThankYouEmail(
218
+ order.customerName,
219
+ order.product,
220
+ order.orderId,
221
+ 'Friendly'
222
+ );
223
+ const result = await service.fetchResults(statusUrl);
224
+ return {
225
+ orderId: order.orderId,
226
+ email: result.getResultJson()
227
+ };
228
+ })
229
+ );
230
+
231
+ console.log(`Generated ${thankYouEmails.length} thank you emails`);
232
+ ```
233
+
234
+ ---
235
+
236
+ ## Use Cases
237
+
238
+ - **Order Confirmations**: Send personalized thank you after purchase
239
+ - **Service Subscriptions**: Thank customers for signing up
240
+ - **Event Registrations**: Acknowledge event sign-ups
241
+ - **Donation Receipts**: Thank donors for contributions
242
+ - **Trial Sign-ups**: Welcome new trial users
243
+ - **Membership Renewals**: Thank customers for renewing
244
+ - **Customer Appreciation**: Build relationships with personalized messages
245
+
246
+ ---
247
+
248
+ ## Voice Tones
249
+
250
+ Choose the appropriate tone for your brand:
251
+
252
+ - **Professional**: Formal, business-appropriate language
253
+ - **Friendly**: Warm, casual, conversational
254
+ - **Enthusiastic**: Energetic, exciting, motivational
255
+ - **Grateful**: Emphasizes appreciation and gratitude
256
+ - **Luxury**: Sophisticated, premium, exclusive
257
+
258
+ ---
259
+
260
+ ## Personalization Features
261
+
262
+ Each email includes:
263
+
264
+ - **Customer's name**: Personal address
265
+ - **Product reference**: Specific item purchased
266
+ - **Order number**: Transaction reference
267
+ - **Brand voice**: Consistent with your tone choice
268
+ - **Call-to-action**: Subtle engagement prompt
269
+ - **Support offer**: Invitation to reach out
270
+
271
+ ---
272
+
273
+ ## API Endpoint
274
+
275
+ **POST** `/ecommerce/thank_you_email`
276
+
277
+ For detailed API specifications, refer to:
278
+ - [Postman Documentation](https://documenter.getpostman.com/view/31106842/2sBXVeGsVo)
279
+ - [Product Page](https://sharpapi.com/en/catalog/ai/e-commerce/custom-thank-you-e-mail-generator)
280
+
281
+ ---
282
+
283
+ ## Related Packages
284
+
285
+ - [@sharpapi/sharpapi-node-product-intro](https://www.npmjs.com/package/@sharpapi/sharpapi-node-product-intro) - Product introductions
286
+ - [@sharpapi/sharpapi-node-product-review-sentiment](https://www.npmjs.com/package/@sharpapi/sharpapi-node-product-review-sentiment) - Review sentiment
287
+ - [@sharpapi/sharpapi-node-paraphrase](https://www.npmjs.com/package/@sharpapi/sharpapi-node-paraphrase) - Text paraphrasing
288
+ - [@sharpapi/sharpapi-node-client](https://www.npmjs.com/package/@sharpapi/sharpapi-node-client) - Full SharpAPI SDK
289
+
290
+ ---
291
+
292
+ ## License
293
+
294
+ This project is licensed under the MIT License. See the [LICENSE.md](LICENSE.md) file for details.
295
+
296
+ ---
297
+
298
+ ## Support
299
+
300
+ - **Documentation**: [SharpAPI.com Documentation](https://sharpapi.com/documentation)
301
+ - **Issues**: [GitHub Issues](https://github.com/sharpapi/sharpapi-node-client/issues)
302
+ - **Email**: contact@sharpapi.com
303
+
304
+ ---
305
+
306
+ **Powered by [SharpAPI](https://sharpapi.com/) - AI-Powered API Workflow Automation**
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@sharpapi/sharpapi-node-thank-you-email",
3
+ "version": "1.0.0",
4
+ "description": "SharpAPI.com Node.js SDK for generating thank you emails",
5
+ "main": "src/index.js",
6
+ "scripts": {
7
+ "test": "jest"
8
+ },
9
+ "keywords": [
10
+ "sharpapi",
11
+ "ai-powered",
12
+ "ai capabilities",
13
+ "api",
14
+ "ai api",
15
+ "api integration",
16
+ "artificial intelligence",
17
+ "natural language processing",
18
+ "restful api",
19
+ "nodejs",
20
+ "software development",
21
+ "e-commerce",
22
+ "thank you email",
23
+ "email generation"
24
+ ],
25
+ "author": "Dawid Makowski <contact@sharpapi.com>",
26
+ "license": "MIT",
27
+ "dependencies": {
28
+ "@sharpapi/sharpapi-node-core": "file:../sharpapi-node-core"
29
+ },
30
+ "devDependencies": {
31
+ "jest": "^29.7.0"
32
+ },
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "https://github.com/sharpapi/sharpapi-node-thank-you-email.git"
39
+ }
40
+ }
@@ -0,0 +1,31 @@
1
+ const { SharpApiCoreService, SharpApiJobTypeEnum } = require('@sharpapi/sharpapi-node-core');
2
+
3
+ /**
4
+ * Service for generating thank you emails using SharpAPI.com
5
+ */
6
+ class SharpApiThankYouEmailService extends SharpApiCoreService {
7
+ /**
8
+ * Generates a personalized thank-you email to the customer after the purchase.
9
+ * The response content does not contain the title, greeting or sender info at the end,
10
+ * so you can personalize the rest of the email easily.
11
+ *
12
+ * @param {string} productName
13
+ * @param {string|null} language
14
+ * @param {number|null} maxLength
15
+ * @param {string|null} voiceTone
16
+ * @param {string|null} context
17
+ * @returns {Promise<string>} - The status URL.
18
+ */
19
+ async generateThankYouEmail(productName, language = null, maxLength = null, voiceTone = null, context = null) {
20
+ const data = { content: productName };
21
+ if (language) data.language = language;
22
+ if (maxLength) data.max_length = maxLength;
23
+ if (voiceTone) data.voice_tone = voiceTone;
24
+ if (context) data.context = context;
25
+
26
+ const response = await this.makeRequest('POST', SharpApiJobTypeEnum.ECOMMERCE_THANK_YOU_EMAIL.url, data);
27
+ return this.parseStatusUrl(response);
28
+ }
29
+ }
30
+
31
+ module.exports = { SharpApiThankYouEmailService };
package/src/index.js ADDED
@@ -0,0 +1,6 @@
1
+ // sharpapi-node-thank-you-email/src/index.js
2
+ const { SharpApiThankYouEmailService } = require('./SharpApiThankYouEmailService');
3
+
4
+ module.exports = {
5
+ SharpApiThankYouEmailService,
6
+ };