diff --git a/api/src/mail/templates/inactive-new-user-day-10.hbs b/api/src/mail/templates/inactive-new-user-day-10.hbs new file mode 100644 index 0000000..0e7c307 --- /dev/null +++ b/api/src/mail/templates/inactive-new-user-day-10.hbs @@ -0,0 +1,147 @@ + + + + + How to Get the Most from textbee.dev + + + +
+
+ +
+ +
+

Hello {{name}},

+ +

We noticed you haven't started using textbee.dev yet. We'd love to + help you get started!

+ +

Many of our users find these specific use cases particularly + valuable:

+ +
+
+

Example: Order Notification System

+
+
+

Let's say you run an e-commerce site and want to send order + updates via SMS:

+ +
+ // Send notification when order status changes
+ const response = await + axios.post('https://api.textbee.dev/api/v1/gateway/{DEVICE_ID}/send-sms', + {
+   recipients: ['+1234567890'],
+   message: 'Your order #12345 has been shipped! Track at + example.com/track/12345'
+ }); +
+ +

This simple integration can significantly improve customer + satisfaction!

+
+
+ +
+
+

Example: Two-Factor Authentication

+
+
+

Enhance your application security with SMS verification codes:

+ +
+ // Generate a random 6-digit code
+ const verificationCode = Math.floor(100000 + Math.random() * + 900000);

+ // Send it via SMS
+ await + axios.post('https://api.textbee.dev/api/v1/gateway/{DEVICE_ID}/send-sms', + {
+   recipients: ['+1234567890'],
+   message: `Your verification code is: + ${verificationCode}`
+ }); +
+
+
+ +

+ + Explore more use cases → + +

+ +
+

Have questions?

+

Feel free to reply to this email, I'll be happy to help you get + started.

+
+ +

If you prefer to explore on your own, here's how to get started:

+ +
    +
  1. Download our Android app + from + dl.textbee.dev
  2. +
  3. Log in to your dashboard + at + textbee.dev/dashboard + and generate a QR code
  4. +
  5. Scan the QR code + with the app to connect your device
  6. +
+ +

+ + View our Quick Start Guide → + +

+ +
+ Access Your + Dashboard +
+ +

If you have any questions or need help with setup, please don't + hesitate to reach out. We're here to ensure you get the most out of + textbee.dev.

+ +

Best regards,
The textbee.dev Team

+ + +
+ + +
+ + \ No newline at end of file diff --git a/api/src/mail/templates/inactive-new-user-day-3.hbs b/api/src/mail/templates/inactive-new-user-day-3.hbs deleted file mode 100644 index 08c1b05..0000000 --- a/api/src/mail/templates/inactive-new-user-day-3.hbs +++ /dev/null @@ -1,85 +0,0 @@ - - - - - Get Started with textbee.dev - - - -
-
-
- -
-

Hello {{name}},

- -

We noticed it's been 3 days since you signed up for textbee.dev, but - you haven't registered any devices yet.

- -

We'd love to help you get the most out of our platform! With - textbee.dev, you can:

- - -

Getting started is quick and easy:

- -
-
- 1 - Install the textbee.dev android app on your device -
-
- 2 - Grant the necessary permissions -
-
- 3 - Login to your - dashboard - and generate a QR code -
-
- 4 - Scan the QR code with the app to register your device -
-
- 5 - Start sending and receiving SMS! -
-
- -
- Register Your Device - Now -
- -

Is there anything we can help you with? If you're experiencing any - issues or have questions, our support team is ready to assist at - support@textbee.dev.

- -

Best regards,
The textbee.dev Team

-
- - -
- - \ No newline at end of file diff --git a/api/src/mail/templates/inactive-new-user.hbs b/api/src/mail/templates/inactive-new-user.hbs index 83d6e7b..0a99fab 100644 --- a/api/src/mail/templates/inactive-new-user.hbs +++ b/api/src/mail/templates/inactive-new-user.hbs @@ -2,81 +2,166 @@ - Get Started with textbee.dev + Getting Started with textbee.dev
+

Hello {{name}},

-

Thank you for signing up for textbee.dev! We noticed you haven't - registered any devices yet.

+

Thank you for creating your textbee.dev account! We're excited to have you with us.

-

With textbee.dev, you can:

- - -

To get started, you'll need to register your first device:

- -
-
- 1 - Install the textbee.dev android app on your device -
-
- 2 - Grant the necessary permissions +
+

What can you do with textbee.dev?

+

Our users are leveraging textbee.dev to:

+ +
+
1
+ Send notifications and alerts - Keep customers informed about orders, appointments, and more
-
- 3 - Login to your dashboard and generate a QR code + +
+
2
+ Implement 2FA with SMS verification - Add an extra layer of security to your applications
-
- 4 - Scan the QR code with the app to register your device -
-
- 5 - Start sending and receiving SMS! + +
+
3
+ Build interactive SMS workflows - Create engaging experiences for your users
+

Getting started with textbee.dev is straightforward:

+ +
    +
  1. Install the Android app - Our app connects securely to your phone's SMS capabilities
  2. +
  3. Register your device - A simple process using a QR code from your dashboard
  4. +
  5. Start sending and receiving messages - Through our intuitive dashboard or API
  6. +
+ -

If you have any questions or need assistance, please don't hesitate - to contact our support team at - support@textbee.dev.

+
+

Need help getting started?

+

We've prepared resources to make your setup experience smooth:

+ +
+ +

If you have questions or run into any issues, I'm here to help. Just reply to this email or contact our support team at support@textbee.dev.

+ +

Looking forward to seeing what you'll build with textbee.dev!

Best regards,
The textbee.dev Team

+ +
diff --git a/api/src/mail/templates/upgrade-to-pro.hbs b/api/src/mail/templates/upgrade-to-pro.hbs index 89c229e..49e87e7 100644 --- a/api/src/mail/templates/upgrade-to-pro.hbs +++ b/api/src/mail/templates/upgrade-to-pro.hbs @@ -2,128 +2,218 @@ - Upgrade to Pro - textbee.dev + Unlock More Capabilities with textbee.dev Pro
+

Hello {{name}},

-

Thank you for using textbee.dev! We hope you're enjoying our service - so far.

+

Thank you for using textbee.dev! We're excited to see that you've been using our platform with {{deviceCount}} connected device{{#if deviceCount > 1}}s{{/if}}.

-

We wanted to let you know that you're currently on our - Free Plan, which provides basic functionality. To - unlock the full potential of textbee.dev, consider upgrading to our - Pro Plan.

+

Many of our users have found that upgrading to Pro helps them scale their SMS capabilities more effectively as they grow. Here's what you can unlock:

-

Special Offer Just For You: - We're extending a - 30% discount - on all Pro plans exclusively for our most active users like you! This - offer is only available for a limited time.

- -

Plan Comparison:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
+
+
+

Unlimited Daily Messages

+

Remove the 50-message daily limit and scale your SMS communications as needed

+
+
+ +
+
+
+

Connect Multiple Devices

+

+ Connect multiple devices to your account to increase your SMS sending capacity. +

+
+
+ +
+
+
+

Priority Support

+

Get faster responses and dedicated assistance for your integration questions

+
+
+ +
+ "textbee.dev Pro has been game-changing for our delivery notifications. We've seen a 28% increase in customer satisfaction since implementing automated SMS updates." +
- Sarah K., E-commerce Business Owner
+
-
FeatureFree PlanPro Plan
Daily Message Limit50Unlimited
Monthly Recipient Limit5005,000
Device Limit1Unlimited
Bulk SMS Recipients50Unlimited
SupportBasicPriority
+

As a valued user, we're offering you a special 30% discount if you upgrade in the next 7 days:

-
-

Pro - Plan Pricing

-
-
-

Monthly

-

$9.99 - $6.99

-

30% off - - limited time

-
-
-

Annual

-

$99.99 - $69.99

-

30% off - - limited time

-
+
+
+

Monthly

+

$9.99/mo

+

$6.99/mo

+

30% savings

+
+ +
+

Annual

+

$99.99/yr

+

$69.99/yr

+

Save 42% vs monthly

- Upgrade to Pro Now -

Hurry! This 30% discount offer is only available for a - limited time.

+ Upgrade to Pro + Learn More
-

If you have any questions about our plans or need assistance, please - feel free to contact us at - support@textbee.dev.

+

Not ready to upgrade? That's completely fine! Your free plan will continue to work as usual. If you have any questions about the Pro features or need help with your current setup, I'm happy to assist.

Best regards,
The textbee.dev Team

+ +
diff --git a/api/src/mail/templates/welcome-1.hbs b/api/src/mail/templates/welcome-1.hbs index ba53ae3..3655abd 100644 --- a/api/src/mail/templates/welcome-1.hbs +++ b/api/src/mail/templates/welcome-1.hbs @@ -1,126 +1,207 @@ + + + Welcome to textbee.dev
-

Welcome to TextBee!

+
-

Hi {{name}},

- -

It's Vernu here, creator of textbee.dev. I built this platform to help you - with all your messaging needs - whether it's sending OTPs, - notifications, or creating automated messaging workflows for your - business.

- -
-

Here are a few tips to get you started:

-
    -
  1. Explore our - Documentation - - Learn how to integrate TextBee with your existing systems
  2. -
  3. Download the Mobile App
  4. -
  5. Access your Dashboard
  6. -
  7. Join our Discord Community
  8. -
  9. Support Our Work
  10. -
  11. Star our GitHub - Repository
  12. -
-
+
+
+

Welcome to textbee.dev!

+

Your gateway to powerful SMS integration

+
+ +

Hi {{name}},

+ +

Welcome to textbee.dev! This platform is designed to provide simple + yet powerful SMS integration for developers and businesses of all + sizes.

+ +
+

Thank you for choosing textbee.dev. We're excited to support your + projects, whether you're building authentication systems for your + customers, notifications, or interactive workflows!

+
+ +

What You Can Build with textbee.dev

+ +
+

User Authentication

+

Implement secure two-factor authentication with SMS verification + codes to protect user accounts and sensitive data.

+
+ +
+

Customer Notifications

+

Send automated order updates, appointment reminders, delivery + status changes, and other important alerts directly to your + customers' phones.

+
+ +
+

Interactive Workflows

+

Create conversational experiences where users can reply to messages + to complete tasks, answer surveys, or trigger automated responses.

+
-
- -

- P.S. - I'd love to hear from you! Why did you choose TextBee? Do you have any - feedback or questions?
- Feel free to reach out to our support team at - contact@textbee.dev.
- We read and respond to all emails as quickly as possible. -

- -
-

- Cheers,
- Vernu
- Creator, textbee.dev +

+ Explore more use cases →

-
-
+

Get Started in Minutes

-
-

Join our community!

- - Discord - Join Discord - - - GitHub - Star on GitHub - - +
+

Quick Setup Guide

+ +
+ +
+
2
+
+

Connect Your Device

+

Visit your dashboard, generate a QR code, and scan it with the + app

+
+
+ +
+
3
+
+

Start Sending

+

Send SMS messages via our dashboard or integrate with our API

+
+
+
+ + + +
+ +

Helpful Resources

+ + + +
+ +

Have questions or feedback? I'd love to hear from you! Feel free to + reply to this email or contact our support team at + support@textbee.dev.

+ +
Patreon - Support on Patreon - +
+

Vernu

+

Founder, textbee.dev

+
+
+
+ +
diff --git a/api/src/users/users.service.ts b/api/src/users/users.service.ts index 3c5077a..12a3d37 100644 --- a/api/src/users/users.service.ts +++ b/api/src/users/users.service.ts @@ -75,43 +75,42 @@ export class UsersService { @Cron('0 12 * * *') // Every day at 12 PM async sendEmailToInactiveNewUsers() { try { - // Get users who signed up between 24-48 hours ago (1-2 days ago) - const twoDaysAgo = new Date(Date.now() - 48 * 60 * 60 * 1000) - const oneDayAgo = new Date(Date.now() - 24 * 60 * 60 * 1000) + // Get users who signed up between 3-4 days ago (not 1-2 days) + const fourDaysAgo = new Date(Date.now() - 4 * 24 * 60 * 60 * 1000) + const threeDaysAgo = new Date(Date.now() - 3 * 24 * 60 * 60 * 1000) const newUsers = await this.userModel.find({ createdAt: { - $gte: twoDaysAgo, - $lt: oneDayAgo, + $gte: fourDaysAgo, + $lt: threeDaysAgo, }, }) - const emailPromises = newUsers.map(async (user) => { + for (const user of newUsers) { try { - // Check if user has any devices registered + // Check if user has any devices registered or has sent/received any SMS const devices = await this.deviceModel.find({ user: user._id }) - if (devices.length === 0) { + if (devices.length === 0 || devices.map(device=>device.sentSMSCount + device.receivedSMSCount).reduce((a,b)=>a+b,0) == 0) { // User hasn't registered any device, send email await this.mailService.sendEmailFromTemplate({ to: user.email, subject: - 'Get Started with textbee.dev - Register Your First Device', + 'Getting Started with textbee.dev - How Can We Help?', template: 'inactive-new-user', context: { name: user.name, registerDeviceUrl: `${process.env.FRONTEND_URL}/dashboard`, }, }) - console.log(`Sent inactive new user email to ${user.email}`) } + // Wait 200ms before processing the next user + await new Promise((resolve) => setTimeout(resolve, 200)) } catch (error) { console.error(`Error processing email for user ${user.email}:`, error) } - }) - - await Promise.allSettled(emailPromises) + } } catch (error) { console.error('Error sending emails to inactive new users:', error) } @@ -120,18 +119,18 @@ export class UsersService { @Cron('0 13 * * *') // Every day at 1 PM async sendEmailToFreeUsers() { try { - // Get users who signed up between 3-4 days ago - const threeDaysAgo = new Date(Date.now() - 3 * 24 * 60 * 60 * 1000) - const fourDaysAgo = new Date(Date.now() - 4 * 24 * 60 * 60 * 1000) + // Get users who signed up between 13-14 days ago + const fourteenDaysAgo = new Date(Date.now() - 14 * 24 * 60 * 60 * 1000) + const thirteenDaysAgo = new Date(Date.now() - 13 * 24 * 60 * 60 * 1000) const usersToEmail = await this.userModel.find({ createdAt: { - $gte: fourDaysAgo, - $lt: threeDaysAgo, + $gte: fourteenDaysAgo, + $lt: thirteenDaysAgo, }, }) - const emailPromises = usersToEmail.map(async (user) => { + for (const user of usersToEmail) { try { const subscription = await this.billingService.getActiveSubscription( user._id.toString(), @@ -140,11 +139,12 @@ export class UsersService { if (subscription?.plan?.name === 'free') { const devices = await this.deviceModel.find({ user: user._id }) - if (devices.length === 0) { + if (devices.length === 0 || devices.map(device=>device.sentSMSCount + device.receivedSMSCount).reduce((a,b)=>a+b,0) == 0) { + // Only send this if they haven't set up any devices after 10-14 days await this.mailService.sendEmailFromTemplate({ to: user.email, - subject: `${user.name?.split(' ')[0]}, Your textbee.dev account is waiting for you!`, - template: 'inactive-new-user-day-3', + subject: `${user.name?.split(' ')[0]}, we'd love to help you get started with textbee.dev`, + template: 'inactive-new-user-day-10', context: { name: user.name, registerDeviceUrl: `${process.env.FRONTEND_URL}/dashboard`, @@ -153,24 +153,27 @@ export class UsersService { console.log(`Sent inactive new user email to ${user.email}`) } else { + // Only send upgrade email to active users who have at least one device await this.mailService.sendEmailFromTemplate({ to: user.email, - subject: `${user.name?.split(' ')[0]}, Upgrade to Pro with a 30% Discount - textbee.dev`, + subject: `${user.name?.split(' ')[0]}, unlock more capabilities with textbee.dev Pro`, template: 'upgrade-to-pro', context: { name: user.name, upgradeUrl: `${process.env.FRONTEND_URL}/checkout/pro`, + deviceCount: devices.length, }, }) console.log(`Sent upgrade to pro email to ${user.email}`) } } + + // Wait 200ms before processing the next user + await new Promise((resolve) => setTimeout(resolve, 200)) } catch (error) { console.error(`Error processing email for user ${user.email}:`, error) } - }) - - await Promise.allSettled(emailPromises) + } } catch (error) { console.error('Error sending emails to free plan users:', error) }