prompt_manager 0.5.7 → 0.5.8

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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/COMMITS.md +196 -0
  4. data/README.md +485 -203
  5. data/docs/.keep +0 -0
  6. data/docs/advanced/custom-keywords.md +421 -0
  7. data/docs/advanced/dynamic-directives.md +535 -0
  8. data/docs/advanced/performance.md +612 -0
  9. data/docs/advanced/search-integration.md +635 -0
  10. data/docs/api/configuration.md +355 -0
  11. data/docs/api/directive-processor.md +431 -0
  12. data/docs/api/prompt-class.md +354 -0
  13. data/docs/api/storage-adapters.md +462 -0
  14. data/docs/assets/favicon.ico +1 -0
  15. data/docs/assets/logo.svg +24 -0
  16. data/docs/core-features/comments.md +48 -0
  17. data/docs/core-features/directive-processing.md +38 -0
  18. data/docs/core-features/erb-integration.md +68 -0
  19. data/docs/core-features/error-handling.md +197 -0
  20. data/docs/core-features/parameter-history.md +76 -0
  21. data/docs/core-features/parameterized-prompts.md +500 -0
  22. data/docs/core-features/shell-integration.md +79 -0
  23. data/docs/development/architecture.md +544 -0
  24. data/docs/development/contributing.md +425 -0
  25. data/docs/development/roadmap.md +234 -0
  26. data/docs/development/testing.md +822 -0
  27. data/docs/examples/advanced.md +523 -0
  28. data/docs/examples/basic.md +688 -0
  29. data/docs/examples/real-world.md +776 -0
  30. data/docs/examples.md +337 -0
  31. data/docs/getting-started/basic-concepts.md +318 -0
  32. data/docs/getting-started/installation.md +97 -0
  33. data/docs/getting-started/quick-start.md +256 -0
  34. data/docs/index.md +230 -0
  35. data/docs/migration/v0.9.0.md +459 -0
  36. data/docs/migration/v1.0.0.md +591 -0
  37. data/docs/storage/activerecord-adapter.md +348 -0
  38. data/docs/storage/custom-adapters.md +176 -0
  39. data/docs/storage/filesystem-adapter.md +236 -0
  40. data/docs/storage/overview.md +427 -0
  41. data/examples/advanced_integrations.rb +52 -0
  42. data/examples/prompts_dir/advanced_demo.txt +79 -0
  43. data/examples/prompts_dir/directive_example.json +1 -0
  44. data/examples/prompts_dir/directive_example.txt +8 -0
  45. data/examples/prompts_dir/todo.json +1 -1
  46. data/improvement_plan.md +996 -0
  47. data/lib/prompt_manager/storage/file_system_adapter.rb +8 -2
  48. data/lib/prompt_manager/version.rb +1 -1
  49. data/mkdocs.yml +146 -0
  50. data/prompt_manager_logo.png +0 -0
  51. metadata +46 -3
  52. data/LICENSE.txt +0 -21
@@ -0,0 +1,776 @@
1
+ # Real World Use Cases
2
+
3
+ This section presents complete, production-ready examples of PromptManager in real-world scenarios.
4
+
5
+ ## E-commerce Platform
6
+
7
+ ### Customer Communication System
8
+
9
+ A complete customer notification system for an e-commerce platform.
10
+
11
+ #### Directory Structure
12
+
13
+ ```
14
+ prompts/
15
+ ├── ecommerce/
16
+ │ ├── orders/
17
+ │ │ ├── confirmation.txt
18
+ │ │ ├── shipped.txt
19
+ │ │ ├── delivered.txt
20
+ │ │ └── cancelled.txt
21
+ │ ├── customers/
22
+ │ │ ├── welcome.txt
23
+ │ │ ├── password_reset.txt
24
+ │ │ └── account_suspension.txt
25
+ │ └── marketing/
26
+ │ ├── newsletter.txt
27
+ │ ├── sale_announcement.txt
28
+ │ └── product_recommendation.txt
29
+ └── shared/
30
+ ├── headers/
31
+ │ ├── brand_header.txt
32
+ │ └── legal_header.txt
33
+ └── footers/
34
+ ├── unsubscribe_footer.txt
35
+ └── contact_footer.txt
36
+ ```
37
+
38
+ #### Implementation
39
+
40
+ ```ruby
41
+ # app/services/customer_notification_service.rb
42
+ class CustomerNotificationService
43
+ include ActiveModel::Validations
44
+
45
+ validates :customer, presence: true
46
+ validates :notification_type, inclusion: {
47
+ in: %w[order_confirmation order_shipped order_delivered order_cancelled
48
+ welcome password_reset account_suspension newsletter sale_announcement]
49
+ }
50
+
51
+ def initialize(customer:, notification_type:, data: {})
52
+ @customer = customer
53
+ @notification_type = notification_type
54
+ @data = data
55
+ end
56
+
57
+ def deliver
58
+ return false unless valid?
59
+
60
+ content = render_notification
61
+ send_notification(content)
62
+ log_notification
63
+
64
+ true
65
+ rescue => e
66
+ handle_error(e)
67
+ false
68
+ end
69
+
70
+ private
71
+
72
+ attr_reader :customer, :notification_type, :data
73
+
74
+ def render_notification
75
+ prompt_id = "ecommerce/#{notification_category}/#{notification_type.split('_').last}"
76
+
77
+ prompt = PromptManager::Prompt.new(
78
+ id: prompt_id,
79
+ erb_flag: true,
80
+ envar_flag: true
81
+ )
82
+
83
+ prompt.render(notification_parameters)
84
+ end
85
+
86
+ def notification_category
87
+ case notification_type
88
+ when /^order_/ then 'orders'
89
+ when /^(welcome|password_reset|account_suspension)$/ then 'customers'
90
+ else 'marketing'
91
+ end
92
+ end
93
+
94
+ def notification_parameters
95
+ base_params = {
96
+ customer_name: customer.full_name,
97
+ customer_email: customer.email,
98
+ customer_id: customer.id,
99
+ company_name: ENV['COMPANY_NAME'],
100
+ support_email: ENV['SUPPORT_EMAIL'],
101
+ website_url: ENV['WEBSITE_URL']
102
+ }
103
+
104
+ base_params.merge(notification_specific_params)
105
+ end
106
+
107
+ def notification_specific_params
108
+ case notification_type
109
+ when 'order_confirmation'
110
+ order_confirmation_params
111
+ when 'order_shipped'
112
+ order_shipped_params
113
+ when 'product_recommendation'
114
+ recommendation_params
115
+ else
116
+ data
117
+ end
118
+ end
119
+
120
+ def order_confirmation_params
121
+ order = data[:order]
122
+ {
123
+ order_id: order.id,
124
+ order_date: order.created_at.strftime('%B %d, %Y'),
125
+ order_total: sprintf('%.2f', order.total),
126
+ order_items: order.line_items.map { |item|
127
+ "#{item.quantity}x #{item.product.name} - $#{sprintf('%.2f', item.total)}"
128
+ },
129
+ estimated_delivery: (order.created_at + order.shipping_method.estimated_days.days).strftime('%B %d, %Y'),
130
+ tracking_url: "#{ENV['WEBSITE_URL']}/orders/#{order.id}/track"
131
+ }
132
+ end
133
+
134
+ def order_shipped_params
135
+ order = data[:order]
136
+ shipment = data[:shipment]
137
+ {
138
+ order_id: order.id,
139
+ tracking_number: shipment.tracking_number,
140
+ carrier: shipment.carrier.name,
141
+ carrier_tracking_url: shipment.carrier_tracking_url,
142
+ estimated_delivery: shipment.estimated_delivery_date.strftime('%B %d, %Y'),
143
+ shipped_items: shipment.line_items.map { |item|
144
+ "#{item.quantity}x #{item.product.name}"
145
+ }
146
+ }
147
+ end
148
+
149
+ def recommendation_params
150
+ recommendations = data[:recommendations]
151
+ {
152
+ recommended_products: recommendations.map { |product|
153
+ {
154
+ name: product.name,
155
+ price: sprintf('%.2f', product.price),
156
+ image_url: product.primary_image.url,
157
+ product_url: "#{ENV['WEBSITE_URL']}/products/#{product.slug}",
158
+ discount_percentage: product.current_discount&.percentage || 0
159
+ }
160
+ },
161
+ recommendation_reason: data[:reason] || 'Based on your recent purchases'
162
+ }
163
+ end
164
+
165
+ def send_notification(content)
166
+ case customer.preferred_notification_method
167
+ when 'email'
168
+ send_email(content)
169
+ when 'sms'
170
+ send_sms(content)
171
+ when 'push'
172
+ send_push_notification(content)
173
+ else
174
+ send_email(content) # Default fallback
175
+ end
176
+ end
177
+
178
+ def send_email(content)
179
+ CustomerNotificationMailer.custom_notification(
180
+ customer: customer,
181
+ subject: email_subject,
182
+ content: content,
183
+ notification_type: notification_type
184
+ ).deliver_later
185
+ end
186
+
187
+ def email_subject
188
+ case notification_type
189
+ when 'order_confirmation' then "Order Confirmation ##{data[:order].id}"
190
+ when 'order_shipped' then "Your Order Has Shipped! ##{data[:order].id}"
191
+ when 'order_delivered' then "Order Delivered ##{data[:order].id}"
192
+ when 'welcome' then "Welcome to #{ENV['COMPANY_NAME']}!"
193
+ when 'password_reset' then "Password Reset Request"
194
+ when 'newsletter' then data[:subject] || "Newsletter"
195
+ else "Notification from #{ENV['COMPANY_NAME']}"
196
+ end
197
+ end
198
+
199
+ def log_notification
200
+ CustomerNotificationLog.create!(
201
+ customer: customer,
202
+ notification_type: notification_type,
203
+ delivery_method: customer.preferred_notification_method,
204
+ data: data,
205
+ delivered_at: Time.current
206
+ )
207
+ end
208
+
209
+ def handle_error(error)
210
+ Rails.logger.error "Notification delivery failed: #{error.message}"
211
+ Rails.logger.error error.backtrace.join("\n")
212
+
213
+ ErrorReportingService.notify(error, {
214
+ customer_id: customer.id,
215
+ notification_type: notification_type,
216
+ data: data
217
+ })
218
+ end
219
+ end
220
+ ```
221
+
222
+ #### Prompt Templates
223
+
224
+ ```ruby
225
+ # prompts/ecommerce/orders/confirmation.txt
226
+ //include shared/headers/brand_header.txt
227
+
228
+ Dear [CUSTOMER_NAME],
229
+
230
+ Thank you for your order! We're excited to confirm that we've received your order and it's being processed.
231
+
232
+ **Order Details:**
233
+ Order #: [ORDER_ID]
234
+ Order Date: [ORDER_DATE]
235
+ Total: $[ORDER_TOTAL]
236
+
237
+ **Items Ordered:**
238
+ <% '[ORDER_ITEMS]'.each do |item| %>
239
+ • <%= item %>
240
+ <% end %>
241
+
242
+ **Shipping Information:**
243
+ Estimated Delivery: [ESTIMATED_DELIVERY]
244
+ You can track your order at: [TRACKING_URL]
245
+
246
+ <% if '[ORDER_TOTAL]'.to_f > 75 %>
247
+ 🎉 **Free Shipping Applied!** - You saved $9.99
248
+ <% end %>
249
+
250
+ We'll send you another email when your order ships with tracking information.
251
+
252
+ //include shared/footers/contact_footer.txt
253
+
254
+ # prompts/ecommerce/orders/shipped.txt
255
+ //include shared/headers/brand_header.txt
256
+
257
+ Great news, [CUSTOMER_NAME]!
258
+
259
+ Your order #[ORDER_ID] has shipped and is on its way to you.
260
+
261
+ **Shipping Details:**
262
+ 📦 Carrier: [CARRIER]
263
+ 🚚 Tracking Number: [TRACKING_NUMBER]
264
+ 📅 Estimated Delivery: [ESTIMATED_DELIVERY]
265
+
266
+ **Track Your Package:**
267
+ [CARRIER_TRACKING_URL]
268
+
269
+ **Items Shipped:**
270
+ <% '[SHIPPED_ITEMS]'.each do |item| %>
271
+ ✓ <%= item %>
272
+ <% end %>
273
+
274
+ Your package should arrive by [ESTIMATED_DELIVERY]. If you have any questions, don't hesitate to reach out!
275
+
276
+ //include shared/footers/contact_footer.txt
277
+
278
+ # prompts/ecommerce/marketing/product_recommendation.txt
279
+ //include shared/headers/brand_header.txt
280
+
281
+ Hi [CUSTOMER_NAME],
282
+
283
+ We thought you might be interested in these products [RECOMMENDATION_REASON]:
284
+
285
+ <% '[RECOMMENDED_PRODUCTS]'.each do |product| %>
286
+ **<%= product['name'] %>**
287
+ <% if product['discount_percentage'] > 0 %>
288
+ ~~$<%= (product['price'].to_f / (1 - product['discount_percentage']/100.0)).round(2) %>~~ **$<%= product['price'] %>** (<%= product['discount_percentage'] %>% OFF!)
289
+ <% else %>
290
+ $<%= product['price'] %>
291
+ <% end %>
292
+ [View Product](<%= product['product_url'] %>)
293
+
294
+ <% end %>
295
+
296
+ These recommendations expire in 48 hours, so don't wait too long!
297
+
298
+ Happy shopping!
299
+ The [COMPANY_NAME] Team
300
+
301
+ //include shared/footers/unsubscribe_footer.txt
302
+ ```
303
+
304
+ #### Usage Examples
305
+
306
+ ```ruby
307
+ # Order confirmation
308
+ CustomerNotificationService.new(
309
+ customer: current_user,
310
+ notification_type: 'order_confirmation',
311
+ data: { order: @order }
312
+ ).deliver
313
+
314
+ # Shipping notification
315
+ CustomerNotificationService.new(
316
+ customer: order.customer,
317
+ notification_type: 'order_shipped',
318
+ data: {
319
+ order: order,
320
+ shipment: shipment
321
+ }
322
+ ).deliver
323
+
324
+ # Product recommendations
325
+ CustomerNotificationService.new(
326
+ customer: user,
327
+ notification_type: 'product_recommendation',
328
+ data: {
329
+ recommendations: RecommendationEngine.for_user(user),
330
+ reason: "based on your recent purchase of #{user.recent_orders.first.product_names.first}"
331
+ }
332
+ ).deliver
333
+ ```
334
+
335
+ ## SaaS Application
336
+
337
+ ### Multi-tenant Onboarding System
338
+
339
+ A complete onboarding workflow for a SaaS platform with multiple client organizations.
340
+
341
+ ```ruby
342
+ # app/services/onboarding_workflow_service.rb
343
+ class OnboardingWorkflowService
344
+ WORKFLOW_STEPS = %w[
345
+ welcome
346
+ account_setup_instructions
347
+ feature_introduction
348
+ integration_guide
349
+ first_milestone_celebration
350
+ getting_help
351
+ ].freeze
352
+
353
+ def initialize(organization:, user:)
354
+ @organization = organization
355
+ @user = user
356
+ @step = 0
357
+ end
358
+
359
+ def start_workflow
360
+ schedule_step(0, delay: 0.minutes)
361
+ end
362
+
363
+ def complete_step(step_name)
364
+ step_index = WORKFLOW_STEPS.index(step_name)
365
+ return false unless step_index
366
+
367
+ @organization.onboarding_progress.update!(
368
+ completed_steps: @organization.onboarding_progress.completed_steps | [step_name],
369
+ current_step: WORKFLOW_STEPS[step_index + 1]
370
+ )
371
+
372
+ schedule_next_step(step_index + 1)
373
+ true
374
+ end
375
+
376
+ private
377
+
378
+ def schedule_step(step_index, delay: 1.day)
379
+ return if step_index >= WORKFLOW_STEPS.length
380
+
381
+ OnboardingEmailJob.set(wait: delay).perform_later(
382
+ organization_id: @organization.id,
383
+ user_id: @user.id,
384
+ step: WORKFLOW_STEPS[step_index]
385
+ )
386
+ end
387
+
388
+ def schedule_next_step(step_index)
389
+ delays = {
390
+ 0 => 0.minutes, # welcome - immediate
391
+ 1 => 1.hour, # setup instructions
392
+ 2 => 1.day, # feature intro
393
+ 3 => 3.days, # integration guide
394
+ 4 => 1.week, # milestone celebration
395
+ 5 => 2.weeks # getting help
396
+ }
397
+
398
+ schedule_step(step_index, delay: delays[step_index] || 3.days)
399
+ end
400
+ end
401
+
402
+ # app/jobs/onboarding_email_job.rb
403
+ class OnboardingEmailJob < ApplicationJob
404
+ def perform(organization_id:, user_id:, step:)
405
+ organization = Organization.find(organization_id)
406
+ user = User.find(user_id)
407
+
408
+ prompt = PromptManager::Prompt.new(
409
+ id: "saas/onboarding/#{step}",
410
+ erb_flag: true
411
+ )
412
+
413
+ content = prompt.render(
414
+ user_name: user.first_name,
415
+ user_email: user.email,
416
+ organization_name: organization.name,
417
+ organization_plan: organization.current_plan.name,
418
+ organization_members_count: organization.users.count,
419
+ setup_url: "#{ENV['APP_URL']}/setup?org=#{organization.id}",
420
+ dashboard_url: "#{ENV['APP_URL']}/dashboard?org=#{organization.id}",
421
+ support_url: "#{ENV['APP_URL']}/support",
422
+ app_name: ENV['APP_NAME'],
423
+ days_since_signup: (Date.current - organization.created_at.to_date).to_i
424
+ )
425
+
426
+ OnboardingMailer.workflow_step(
427
+ user: user,
428
+ organization: organization,
429
+ step: step,
430
+ content: content
431
+ ).deliver_now
432
+
433
+ # Track email delivery
434
+ organization.onboarding_progress.increment!("#{step}_emails_sent")
435
+ end
436
+ end
437
+ ```
438
+
439
+ #### Onboarding Prompt Templates
440
+
441
+ ```ruby
442
+ # prompts/saas/onboarding/welcome.txt
443
+ <%= erb_flag = true %>
444
+
445
+ Hi [USER_NAME]! 👋
446
+
447
+ Welcome to [APP_NAME]! We're thrilled to have [ORGANIZATION_NAME] join our platform.
448
+
449
+ Over the next few weeks, I'll be sending you a series of emails to help you get the most out of [APP_NAME]. Here's what to expect:
450
+
451
+ 📋 **Next up (in about an hour):** Account setup guide
452
+ 🚀 **Tomorrow:** Feature walkthrough
453
+ 🔧 **In 3 days:** Integration setup help
454
+ 🎉 **Next week:** Celebrating your first milestone
455
+
456
+ **Quick Start:**
457
+ Ready to dive in right now? Visit your dashboard: [DASHBOARD_URL]
458
+
459
+ <% if '[ORGANIZATION_PLAN]' == 'trial' %>
460
+ ⏰ **Trial Reminder:** You have <%= 30 - '[DAYS_SINCE_SIGNUP]'.to_i %> days left in your trial. We'll help you make the most of it!
461
+ <% end %>
462
+
463
+ Looking forward to your success!
464
+ Sarah from the [APP_NAME] team
465
+
466
+ P.S. Hit reply anytime - I read every email personally! 📧
467
+
468
+ # prompts/saas/onboarding/account_setup_instructions.txt
469
+ <%= erb_flag = true %>
470
+
471
+ Hey [USER_NAME],
472
+
473
+ Ready to set up your [APP_NAME] account? Let's get [ORGANIZATION_NAME] fully configured!
474
+
475
+ **Your 5-Minute Setup Checklist:**
476
+ □ Complete your organization profile
477
+ □ Invite your team members (<%= '[ORGANIZATION_MEMBERS_COUNT]'.to_i == 1 ? "You're flying solo for now!" : "You have #{[ORGANIZATION_MEMBERS_COUNT].to_i} members so far" %>)
478
+ □ Connect your first integration
479
+ □ Set up your preferences
480
+ □ Take our product tour
481
+
482
+ **Start Setup: [SETUP_URL]**
483
+
484
+ <% if '[ORGANIZATION_PLAN]' == 'enterprise' %>
485
+ 🏢 **Enterprise Customer?**
486
+ Your dedicated success manager will reach out within 24 hours to schedule a personalized onboarding call.
487
+ <% end %>
488
+
489
+ **Need help?**
490
+ - 📖 Check our setup guide: [SETUP_URL]/guide
491
+ - 💬 Live chat support: [SUPPORT_URL]
492
+ - 📧 Just reply to this email
493
+
494
+ You've got this!
495
+ Sarah 🌟
496
+
497
+ # prompts/saas/onboarding/feature_introduction.txt
498
+ <%= erb_flag = true %>
499
+
500
+ Hi [USER_NAME]!
501
+
502
+ Hope you're settling in well with [APP_NAME]! Today I want to show you three features that [ORGANIZATION_PLAN] customers love most:
503
+
504
+ **🎯 Smart Analytics**
505
+ Get insights into your data with our AI-powered analytics. Perfect for understanding trends and making data-driven decisions.
506
+ [Learn more →]([DASHBOARD_URL]/analytics)
507
+
508
+ **🔄 Automation Workflows**
509
+ <% if '[ORGANIZATION_PLAN]' == 'enterprise' %>
510
+ Set up complex automation rules to streamline your processes. Enterprise customers can create unlimited workflows!
511
+ <% else %>
512
+ Automate repetitive tasks with our visual workflow builder. Your plan includes up to 10 active workflows.
513
+ <% end %>
514
+ [See examples →]([DASHBOARD_URL]/workflows)
515
+
516
+ **👥 Team Collaboration**
517
+ Share dashboards, leave comments, and keep everyone in sync.
518
+ [Invite teammates →]([SETUP_URL]/team)
519
+
520
+ **Pro tip:** Most successful teams start with automation workflows. They save an average of 5 hours per week!
521
+
522
+ Want a personal demo of any of these features? Just reply and I'll set something up.
523
+
524
+ Cheers,
525
+ Sarah 🚀
526
+
527
+ # prompts/saas/onboarding/integration_guide.txt
528
+ <%= erb_flag = true %>
529
+
530
+ Hey [USER_NAME],
531
+
532
+ Ready to supercharge [APP_NAME] with integrations? Let's connect your existing tools!
533
+
534
+ **Popular Integrations for [ORGANIZATION_PLAN] teams:**
535
+
536
+ 🔗 **CRM Integration** (Salesforce, HubSpot, Pipedrive)
537
+ Sync your customer data automatically
538
+ [Connect now →]([SETUP_URL]/integrations/crm)
539
+
540
+ 📧 **Email Marketing** (Mailchimp, ConvertKit, Klaviyo)
541
+ Trigger campaigns based on your [APP_NAME] data
542
+ [Set up →]([SETUP_URL]/integrations/email)
543
+
544
+ 📊 **Analytics** (Google Analytics, Mixpanel, Segment)
545
+ Get deeper insights by combining data sources
546
+ [Integrate →]([SETUP_URL]/integrations/analytics)
547
+
548
+ <% if '[ORGANIZATION_PLAN]' == 'enterprise' %>
549
+ 🏢 **Enterprise Exclusive:**
550
+ - Custom API integrations
551
+ - SSO setup (SAML, OAuth)
552
+ - Database connections
553
+ [Contact your success manager for setup]
554
+ <% end %>
555
+
556
+ **Integration taking longer than expected?**
557
+ Our integration specialists can help! Book a free 30-minute session: [SUPPORT_URL]/integration-help
558
+
559
+ Keep building,
560
+ Sarah ⚡
561
+
562
+ # prompts/saas/onboarding/first_milestone_celebration.txt
563
+ <%= erb_flag = true %>
564
+
565
+ 🎉 [USER_NAME], you did it!
566
+
567
+ It's been a week since [ORGANIZATION_NAME] joined [APP_NAME], and I wanted to celebrate some awesome progress:
568
+
569
+ **Your Week 1 Achievements:**
570
+ <% days_active = '[DAYS_SINCE_SIGNUP]'.to_i %>
571
+ ✅ Account active for <%= days_active %> <%= days_active == 1 ? 'day' : 'days' %>
572
+ <% if '[ORGANIZATION_MEMBERS_COUNT]'.to_i > 1 %>
573
+ ✅ Team of <%= '[ORGANIZATION_MEMBERS_COUNT]' %> members onboarded
574
+ <% end %>
575
+ ✅ Dashboard configured and personalized
576
+
577
+ **What's Working Well:**
578
+ Most teams at your stage are focusing on:
579
+ - Setting up their first automated workflows (saves ~5 hours/week)
580
+ - Connecting 2-3 key integrations
581
+ - Training team members on core features
582
+
583
+ **Quick Win for Week 2:**
584
+ Try our "Smart Automation" feature - it suggests workflows based on your usage patterns.
585
+ [Check it out →]([DASHBOARD_URL]/automation/suggestions)
586
+
587
+ <% if '[ORGANIZATION_PLAN]' == 'trial' %>
588
+ ⏰ **Trial Update:** <%= 30 - days_active %> days remaining
589
+ Ready to upgrade? Current customers save 20% on annual plans: [DASHBOARD_URL]/billing
590
+ <% end %>
591
+
592
+ You're building something great! Keep going 💪
593
+
594
+ Sarah & the [APP_NAME] team
595
+
596
+ P.S. Have a success story to share? I'd love to hear it! 🌟
597
+ ```
598
+
599
+ ## Healthcare System
600
+
601
+ ### Patient Communication Platform
602
+
603
+ A HIPAA-compliant patient communication system for healthcare providers.
604
+
605
+ ```ruby
606
+ # app/services/patient_communication_service.rb
607
+ class PatientCommunicationService
608
+ include EncryptionHelper
609
+
610
+ def initialize(patient:, provider:, communication_type:)
611
+ @patient = patient
612
+ @provider = provider
613
+ @communication_type = communication_type
614
+ validate_hipaa_compliance!
615
+ end
616
+
617
+ def send_appointment_reminder(appointment)
618
+ send_secure_communication(
619
+ 'healthcare/appointments/reminder',
620
+ appointment_reminder_params(appointment)
621
+ )
622
+ end
623
+
624
+ def send_test_results(test_result)
625
+ send_secure_communication(
626
+ 'healthcare/results/lab_results',
627
+ test_results_params(test_result)
628
+ )
629
+ end
630
+
631
+ def send_medication_reminder(prescription)
632
+ send_secure_communication(
633
+ 'healthcare/medications/reminder',
634
+ medication_params(prescription)
635
+ )
636
+ end
637
+
638
+ private
639
+
640
+ def send_secure_communication(prompt_id, parameters)
641
+ # Generate encrypted message
642
+ prompt = PromptManager::Prompt.new(id: prompt_id)
643
+ content = prompt.render(parameters)
644
+
645
+ encrypted_content = encrypt_phi(content)
646
+
647
+ # Send via secure channel
648
+ case @patient.preferred_communication_method
649
+ when 'secure_email'
650
+ send_encrypted_email(encrypted_content)
651
+ when 'patient_portal'
652
+ post_to_patient_portal(encrypted_content)
653
+ when 'secure_sms'
654
+ send_encrypted_sms(encrypted_content)
655
+ end
656
+
657
+ # Log communication (HIPAA audit trail)
658
+ log_patient_communication(prompt_id, parameters)
659
+ end
660
+
661
+ def appointment_reminder_params(appointment)
662
+ {
663
+ patient_first_name: @patient.first_name,
664
+ appointment_date: appointment.scheduled_at.strftime('%A, %B %d, %Y'),
665
+ appointment_time: appointment.scheduled_at.strftime('%I:%M %p'),
666
+ provider_name: @provider.full_name,
667
+ provider_title: @provider.title,
668
+ clinic_name: @provider.clinic.name,
669
+ clinic_address: @provider.clinic.address,
670
+ clinic_phone: format_phone(@provider.clinic.phone),
671
+ appointment_type: appointment.appointment_type.name,
672
+ preparation_instructions: appointment.preparation_instructions,
673
+ insurance_reminder: insurance_verification_needed?(appointment)
674
+ }
675
+ end
676
+
677
+ def test_results_params(test_result)
678
+ {
679
+ patient_first_name: @patient.first_name,
680
+ test_name: test_result.test_type.name,
681
+ test_date: test_result.collected_at.strftime('%B %d, %Y'),
682
+ ordering_provider: test_result.ordering_provider.full_name,
683
+ results_summary: sanitize_phi(test_result.summary),
684
+ next_steps: test_result.recommendations,
685
+ followup_needed: test_result.requires_followup?,
686
+ portal_url: "#{ENV['PATIENT_PORTAL_URL']}/results/#{test_result.secure_id}"
687
+ }
688
+ end
689
+
690
+ def validate_hipaa_compliance!
691
+ raise 'HIPAA compliance not configured' unless Rails.application.config.hipaa_enabled
692
+ raise 'Encryption not available' unless encryption_available?
693
+ raise 'Audit logging disabled' unless audit_logging_enabled?
694
+ end
695
+ end
696
+ ```
697
+
698
+ #### Healthcare Prompt Templates
699
+
700
+ ```ruby
701
+ # prompts/healthcare/appointments/reminder.txt
702
+ Dear [PATIENT_FIRST_NAME],
703
+
704
+ This is a friendly reminder about your upcoming appointment:
705
+
706
+ **Appointment Details:**
707
+ 📅 Date: [APPOINTMENT_DATE]
708
+ 🕐 Time: [APPOINTMENT_TIME]
709
+ 👩‍⚕️ Provider: [PROVIDER_NAME], [PROVIDER_TITLE]
710
+ 🏥 Location: [CLINIC_NAME]
711
+ 📍 Address: [CLINIC_ADDRESS]
712
+ 📞 Phone: [CLINIC_PHONE]
713
+
714
+ **Appointment Type:** [APPOINTMENT_TYPE]
715
+
716
+ <% if ![PREPARATION_INSTRUCTIONS].empty? %>
717
+ **Important Preparation Instructions:**
718
+ [PREPARATION_INSTRUCTIONS]
719
+ <% end %>
720
+
721
+ <% if [INSURANCE_REMINDER] %>
722
+ **Insurance Reminder:**
723
+ Please bring your current insurance card and a valid photo ID.
724
+ <% end %>
725
+
726
+ **Need to reschedule?**
727
+ Please call us at [CLINIC_PHONE] at least 24 hours in advance.
728
+
729
+ **Running late?**
730
+ Please call to let us know - we'll do our best to accommodate you.
731
+
732
+ Thank you for choosing [CLINIC_NAME] for your healthcare needs.
733
+
734
+ ---
735
+ This message contains confidential medical information intended only for [PATIENT_FIRST_NAME]. If you received this in error, please contact [CLINIC_PHONE] immediately.
736
+
737
+ # prompts/healthcare/results/lab_results.txt
738
+ Dear [PATIENT_FIRST_NAME],
739
+
740
+ Your recent lab results from [TEST_DATE] are now available.
741
+
742
+ **Test:** [TEST_NAME]
743
+ **Ordered by:** [ORDERING_PROVIDER]
744
+
745
+ **Results Summary:**
746
+ [RESULTS_SUMMARY]
747
+
748
+ <% if [NEXT_STEPS] %>
749
+ **Recommended Next Steps:**
750
+ [NEXT_STEPS]
751
+ <% end %>
752
+
753
+ <% if [FOLLOWUP_NEEDED] %>
754
+ **⚠️ Follow-up Required**
755
+ Please schedule a follow-up appointment to discuss these results in detail.
756
+ Call [CLINIC_PHONE] or use our patient portal.
757
+ <% else %>
758
+ **✅ No Follow-up Needed**
759
+ These results are within normal ranges. Continue your current care plan.
760
+ <% end %>
761
+
762
+ **View Complete Results:**
763
+ Log into your patient portal for detailed results and reference ranges:
764
+ [PORTAL_URL]
765
+
766
+ **Questions about your results?**
767
+ Contact your care team at [CLINIC_PHONE] or send a secure message through the patient portal.
768
+
769
+ Best regards,
770
+ [ORDERING_PROVIDER] and Care Team
771
+
772
+ ---
773
+ CONFIDENTIAL: This message contains protected health information. Do not forward or share.
774
+ ```
775
+
776
+ These real-world examples demonstrate how PromptManager can be used to build sophisticated, production-ready communication systems across different industries while maintaining security, compliance, and scalability requirements.