wco_email 0.1.1.135 → 0.1.1.136

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e9fd5d50e755cf594af336712e3ab9b4c49b72b53062c03ade0967df88d490d
4
- data.tar.gz: 663fa40fd2689e027fb8bad8df84091ff069335e289e349c355058128ec32859
3
+ metadata.gz: c920c0ce8ae8d6be19d6082a242f6d9d61ede4b85bfcdca7a680cca133abcf49
4
+ data.tar.gz: 3cf6dbdf328d8b996ed111df5ad3e7880b4704439ac5be41783d36e4dcd17185
5
5
  SHA512:
6
- metadata.gz: '085267ff9a0bd5946de4b9ec80ab22a447cc0aa02d272c13d9ec96ed1073626bdea18f8f2184253c78dc76e3066fddfc3869634e11888bc55fb65e98573ff768'
7
- data.tar.gz: 4947bf26f8afe7e27c3c6ead6526cbac0799a4d191deceaaac4e1fe281ef3733f042b52b59778b3f73438d1735d55eb07612a75012fdc53f7da9b0b5fd103d45
6
+ metadata.gz: 41f0243a85a81ca840c9c20d8926e84fe02cdc3b6fad8218c6ea0145e50538fe157e55a9491d9fda3fa9a425c65d52e3330299c9fe4435fdbc453f6abd3ccee6
7
+ data.tar.gz: d323ddf5c01c912a42a2c272a949fdaadc2548e51a3f65a570ce2757bcb07d16c1313c68a096fa376a0fd6e633737a7499d025bfdfa8e081ea7ca739e8cda67b
@@ -3,6 +3,35 @@ class WcoEmail::MessagesController < WcoEmail::ApplicationController
3
3
 
4
4
  before_action :set_lists, except: %i| show_iframe |
5
5
 
6
+ def autorespond
7
+ @message = WcoEmail::Message.find params[:id]
8
+ authorize! :show, @message
9
+
10
+ task = 'You are an administrative assistant. Write a brief email response to the following email. exclude subject. exclude footer. exclude signature. format as <p></p> html paragraphs.'
11
+ content = @message.part_txt
12
+ outs = Wco::AiWriter.do_call(task, content)
13
+ puts! outs, 'outs'
14
+
15
+
16
+ @ctx = WcoEmail::Context.new({
17
+ bcc_self: true,
18
+ body: outs,
19
+ email_template: WcoEmail::EmailTemplate.blank,
20
+ from_email: @message.to,
21
+ lead: @message.lead,
22
+ reply_to_message_id: @message.id,
23
+ # send_at: Time.now,
24
+ subject: @message.subject,
25
+ })
26
+
27
+ if @ctx.save
28
+ flash_notice 'Saved.'
29
+ else
30
+ flash_alert @ctx
31
+ end
32
+ redirect_to request.referrer
33
+ end
34
+
6
35
  def show
7
36
  @client ||= Aws::S3::Client.new(::SES_S3_CREDENTIALS)
8
37
  @message = WcoEmail::Message.find params[:id]
@@ -46,4 +46,5 @@
46
46
  = paginate @messages, param_name: :messages_page
47
47
 
48
48
  - msg = @messages.last
49
- = render '/wco_email/contexts/form_reply', lead_id: msg.lead_id, message: msg, ctx: WcoEmail::Context.new({ from_email: msg.to&.downcase, subject: msg.subject, email_template_id: ET.find_by( slug: 'blank').id })
49
+ = render '/wco_email/contexts/form_reply', lead_id: msg.lead_id, message: msg, ctx: WcoEmail::Context.new({ from_email: msg.to&.downcase, subject: msg.subject, email_template_id: ET.find_by( slug: 'blank').id })
50
+ = button_to 'autorespond', message_autorespond_path(msg), data: { confirm: 'Are you sure?' }
@@ -1,3 +1,5 @@
1
1
 
2
2
  STRIPE_PK = 'pk_test_qr1QPmSpLdBFt1F7itdWJOj3'
3
3
  STRIPE_SK = 'sk_test_ARuaXffdANoXLKAwUXDcp0v0'
4
+
5
+ OPENAI_API_KEY = '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'
data/config/routes.rb CHANGED
@@ -60,7 +60,8 @@ WcoEmail::Engine.routes.draw do
60
60
  resources :lead_action_templates
61
61
  resources :lead_actions
62
62
 
63
- get 'messages/:id/iframe', to: 'messages#show_iframe', as: :message_iframe
63
+ get 'messages/:id/iframe', to: 'messages#show_iframe', as: :message_iframe
64
+ post 'messages/:id/autorespond', to: 'messages#autorespond', as: :message_autorespond
64
65
  resources :messages
65
66
 
66
67
  post 'message_stub/:id/churn', to: 'message_stubs#churn', as: :churn_message_stub
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wco_email
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1.135
4
+ version: 0.1.1.136
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev