SMS and Email Setup
SMS and Email Setup
Complete guide to configuring SMS (Twilio) and Email (SMTP) notifications in MyClinicSoft.
Overview
MyClinicSoft supports sending notifications via:
- SMS - Using Twilio integration
- Email - Using SMTP configuration
Notifications can be sent for:
- Appointment reminders
- Payment reminders
- Lab result notifications
- Birthday greetings
- Health reminders
- Medication reminders
- And more
SMS Setup (Twilio)
What is Twilio?
Twilio is a cloud communications platform that allows applications to send SMS messages programmatically.
Prerequisites
- A Twilio account (sign up at twilio.com)
- A Twilio phone number
- Account credentials (Account SID and Auth Token)
Step 1: Create Twilio Account
- Go to https://www.twilio.com/try-twilio
- Sign up for a free account
- Verify your email address
- Verify your phone number
Free Trial:
- $15 credit (approximately 1,000 SMS)
- Can only send to verified numbers
- Messages include "Sent from a Twilio trial account"
Paid Account:
- Remove trial limitations
- Send to any number
- No trial message prefix
- Volume discounts available
Step 2: Get a Phone Number
- Log in to Twilio console
- Go to Phone Numbers → Buy a Number
- Select your country
- Choose capabilities:
- ✅ SMS
- ✅ MMS (optional)
- ⬜ Voice (not needed)
- Search for available numbers
- Purchase a number
Costs:
- Philippines: ~$1-2/month per number
- USA: ~$1/month per number
- Outgoing SMS: ~$0.0075 per message (varies by country)
Step 3: Get Account Credentials
- Go to Twilio Console Dashboard
- Find your credentials:
- Account SID - Starts with "AC"
- Auth Token - Click to reveal
Keep These Secret! Never share or commit to version control.
Step 4: Configure MyClinicSoft
Add to your .env.local file:
TWILIO_ACCOUNT_SID=your_account_sid_here
TWILIO_AUTH_TOKEN=your_auth_token_here
TWILIO_PHONE_NUMBER=+1234567890
Format Notes:
- Account SID: Starts with "AC" followed by 32 characters
- Auth Token: 32-character string
- Phone Number: International format with +, no spaces or dashes
- Example: +639171234567 (Philippines)
- Example: +14155551234 (USA)
Step 5: Test SMS
-
Restart your application:
npm run dev -
Test sending SMS:
- Go to Appointments
- Create a test appointment
- Click Send Reminder
- Check if SMS received
Troubleshooting:
- Check phone number format (must include country code)
- Verify credentials are correct
- Check Twilio console logs
- Ensure phone number is verified (if trial account)
SMS Best Practices
- Message Length - Keep under 160 characters
- Timing - Send during appropriate hours (8 AM - 8 PM)
- Opt-out - Include opt-out instructions
- Cost - Monitor usage to control costs
- Compliance - Follow local SMS regulations
SMS Message Templates
Customize in Settings → Notifications → SMS Templates
Available Variables:
{patientName}- Patient's name{doctorName}- Doctor's name{appointmentDate}- Date of appointment{appointmentTime}- Time of appointment{clinicName}- Your clinic name{clinicPhone}- Your clinic phone
Example Appointment Reminder:
Hi {patientName}, this is a reminder of your appointment with Dr. {doctorName}
tomorrow at {appointmentTime}. Reply CANCEL to cancel. - {clinicName}
Email Setup (SMTP)
What is SMTP?
SMTP (Simple Mail Transfer Protocol) is the standard protocol for sending emails.
Email Provider Options
Choose one:
Option 1: Gmail (Recommended for Small Clinics)
Pros:
- Free for low volume
- Reliable
- Easy setup
Cons:
- 500 emails/day limit
- Requires App Password
Setup:
- Enable 2-factor authentication on Gmail
- Generate App Password:
- Go to Google Account → Security
- Click "App passwords"
- Select "Mail" and your device
- Copy generated password
- Use these settings:
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your-email@gmail.com
SMTP_PASS=your_app_password_here
SMTP_FROM=your-email@gmail.com
Option 2: SendGrid
Pros:
- 100 emails/day free
- Professional service
- Good deliverability
- Detailed analytics
Cons:
- Requires signup
Setup:
- Sign up at sendgrid.com
- Create API key
- Verify sender identity
- Use these settings:
SMTP_HOST=smtp.sendgrid.net
SMTP_PORT=587
SMTP_USER=apikey
SMTP_PASS=your_sendgrid_api_key
SMTP_FROM=your-verified-email@yourdomain.com
Option 3: Amazon SES
Pros:
- Very cheap ($0.10 per 1,000 emails)
- Scalable
- Reliable
Cons:
- More complex setup
- Requires AWS account
Setup:
- Create AWS account
- Verify email address/domain
- Create SMTP credentials
- Request production access (exit sandbox)
SMTP_HOST=email-smtp.us-east-1.amazonaws.com
SMTP_PORT=587
SMTP_USER=your_smtp_username
SMTP_PASS=your_smtp_password
SMTP_FROM=your-verified-email@yourdomain.com
Option 4: Your Own Email Server
If you have your own email server:
SMTP_HOST=mail.yourdomain.com
SMTP_PORT=587
SMTP_USER=noreply@yourdomain.com
SMTP_PASS=your_email_password
SMTP_FROM=noreply@yourdomain.com
Common Ports:
- 587 - TLS (recommended)
- 465 - SSL
- 25 - Unencrypted (not recommended)
Configure MyClinicSoft
Add to your .env.local file:
SMTP_HOST=your_smtp_host
SMTP_PORT=587
SMTP_USER=your_smtp_username
SMTP_PASS=your_smtp_password
SMTP_FROM=noreply@yourclinic.com
Test Email
- Restart your application
- Test sending email:
- Go to Appointments
- Create test appointment with your email
- Click Send Reminder
- Check if email received
Check Spam Folder if not received in inbox.
Email Best Practices
- Professional From Address - Use your domain, not Gmail
- Clear Subject Lines - Indicate purpose clearly
- Plain Text + HTML - Support both formats
- Unsubscribe Link - Allow patients to opt out
- DKIM/SPF - Configure for better deliverability
- Test Before Sending - Always test new templates
Email Templates
Customize in Settings → Notifications → Email Templates
Template Components:
- Subject line
- HTML body
- Plain text body
- Header/Footer
Available Variables: Same as SMS templates plus:
{clinicAddress}- Your clinic address{clinicWebsite}- Your website URL{unsubscribeLink}- Opt-out link
Example Appointment Reminder:
Subject: Appointment Reminder - {appointmentDate}
Body:
<!DOCTYPE html>
<html>
<head>
<style>
body { font-family: Arial, sans-serif; }
.header { background-color: #007bff; color: white; padding: 20px; }
.content { padding: 20px; }
.footer { background-color: #f8f9fa; padding: 10px; font-size: 12px; }
</style>
</head>
<body>
<div class="header">
<h1>{clinicName}</h1>
</div>
<div class="content">
<p>Dear {patientName},</p>
<p>This is a reminder of your upcoming appointment:</p>
<ul>
<li><strong>Doctor:</strong> Dr. {doctorName}</li>
<li><strong>Date:</strong> {appointmentDate}</li>
<li><strong>Time:</strong> {appointmentTime}</li>
</ul>
<p>If you need to cancel or reschedule, please call us at {clinicPhone}.</p>
<p>Thank you!</p>
</div>
<div class="footer">
<p>{clinicName} | {clinicAddress} | {clinicPhone}</p>
<p><a href="{unsubscribeLink}">Unsubscribe</a></p>
</div>
</body>
</html>
Notification Settings
Configure notifications in Settings → Notifications
General Settings
- Enable Notifications - Master on/off switch
- Default Send Method - SMS, Email, or Both
- Quiet Hours - Don't send between 10 PM - 7 AM
- Rate Limiting - Max messages per hour/day
- Retry Failed - Retry failed sends (yes/no)
Notification Types
Enable/disable each notification type:
Appointment Notifications:
- ✅ Appointment confirmation (immediately)
- ✅ Appointment reminder (24 hours before)
- ✅ Appointment reminder (2 hours before)
- ✅ Appointment cancelled
- ⬜ Appointment rescheduled
Payment Notifications:
- ✅ Payment received
- ✅ Payment reminder (7 days overdue)
- ✅ Payment reminder (14 days overdue)
- ⬜ Payment plan reminder
Clinical Notifications:
- ✅ Lab results ready
- ✅ Prescription ready for pickup
- ⬜ Prescription refill reminder
General Notifications:
- ✅ Birthday greetings
- ⬜ Health reminders
- ⬜ Vaccination reminders
- ⬜ Annual checkup reminder
Patient Preferences
Patients can control their notification preferences:
Patient Portal Settings:
- Choose notification method (SMS/Email/Both)
- Opt out of certain types
- Update contact information
- Unsubscribe from all
Automated Notifications
Cron Jobs
Automated notifications run via cron jobs:
Configured Notifications:
- Appointment reminders (daily at 9 AM)
- Payment reminders (daily at 10 AM)
- Birthday greetings (daily at 8 AM)
- Health reminders (daily at 12 PM)
- Medication reminders (4x daily)
See Cron Job Setup for configuration details.
Manual Sending
Send notifications manually:
Single Patient:
- Go to patient record
- Click Send Notification
- Choose type and method
- Edit message if needed
- Click Send
Bulk Sending:
- Go to Notifications → Send Bulk
- Select recipients:
- All patients
- Patients with appointments today
- Patients with upcoming birthdays
- Custom filter
- Choose notification type
- Preview message
- Click Send to All
Monitoring and Logs
Notification History
View sent notifications:
Access: Notifications → History
View:
- Date and time sent
- Recipient
- Type (SMS/Email)
- Status (Sent/Failed/Pending)
- Error message (if failed)
Filter By:
- Date range
- Patient
- Type
- Status
- Method
Delivery Status
SMS Status:
- Sent - Delivered to carrier
- Delivered - Confirmed delivery
- Failed - Not delivered
- Undelivered - Invalid number
Email Status:
- Sent - Sent from server
- Delivered - Received by recipient
- Opened - Email opened (if tracking enabled)
- Bounced - Invalid email
- Spam - Marked as spam
Failed Notifications
Handle failed notifications:
- Go to Notifications → Failed
- Review failures
- For each:
- Check error message
- Verify contact information
- Correct if needed
- Retry sending
Common Failure Reasons:
- Invalid phone number/email
- Recipient blocked sender
- Network error
- Quota exceeded
- Credentials invalid
Cost Management
Monitoring Costs
Twilio Costs:
- View usage in Twilio console
- Set up usage alerts
- Monitor spending daily
SendGrid/SES:
- View dashboard analytics
- Set budget alerts
- Monitor monthly totals
Reducing Costs
- Batch Messages - Send at optimal times
- Opt-in Only - Only send to those who want them
- Consolidate - Combine multiple notifications
- Email When Possible - Email is cheaper than SMS
- Remove Inactive - Remove patients who never respond
- Shorten Messages - Keep SMS under 160 characters
Usage Reports
Generate usage reports:
Navigate to: Reports → Notifications
Reports:
- Messages sent by type
- Messages sent by method
- Cost by period
- Delivery rate
- Response rate
Compliance
Privacy Regulations
PH DPA / GDPR Compliance:
- Obtain consent before sending
- Provide opt-out method
- Store consent records
- Honor unsubscribe requests
- Protect contact information
Medical Privacy
HIPAA-like Considerations:
- Don't include sensitive health info in SMS
- Use secure email when possible
- Include disclaimer in messages
- Log all communications
Required Disclaimers
SMS Messages:
Reply STOP to unsubscribe. Message and data rates may apply.
Emails:
You are receiving this email because you are a patient of [Clinic Name].
To unsubscribe, click here: [unsubscribe link]
Troubleshooting
SMS Not Sending
Check:
- Twilio credentials correct in
.env.local - Phone number format (include + and country code)
- Twilio account has credit
- Number not on do-not-call list
- View Twilio console logs
Email Not Sending
Check:
- SMTP credentials correct
- SMTP port correct (587 for TLS)
- From email address verified
- Not exceeding daily limit
- Check spam folder
- Review email server logs
Notifications Delayed
Check:
- Cron jobs running (see cron logs)
- Queue not backed up
- Rate limiting settings
- Server performance
High Costs
Solutions:
- Review sending frequency
- Check for unnecessary sends
- Switch some to email
- Optimize message length
- Remove inactive recipients
Best Practices
- Test Thoroughly - Test before going live
- Start Small - Begin with important notifications only
- Monitor Closely - Watch delivery rates and costs
- Get Consent - Always ask permission first
- Provide Value - Send helpful information only
- Professional Tone - Maintain professional communication
- Timing - Send at appropriate times
- Mobile-Friendly - Optimize for mobile viewing
- Track Results - Monitor open and response rates
- Continuously Improve - Refine based on feedback
Security
- Protect Credentials - Never commit to version control
- Use Environment Variables - Store in
.env.local - Rotate Passwords - Change periodically
- Monitor Usage - Watch for unauthorized use
- Secure Access - Limit who can send notifications
- Encrypt Data - Use TLS/SSL for transmission
- Audit Trail - Log all notification activities