Class: Silas::AgentMailbox
- Inherits:
-
ActionMailbox::Base
- Object
- ActionMailbox::Base
- Silas::AgentMailbox
- Defined in:
- app/mailboxes/silas/agent_mailbox.rb
Overview
Action Mailbox reference inbound: maps an email thread to a Silas session. A new thread starts a session; a reply (same References/In-Reply-To root) continues it. Route inbound mail here from the host's ApplicationMailbox:
routing all: "Silas::AgentMailbox"
Requires app/agent/channels/email.rb (Agent::Channels::Email) to exist.
Class Method Summary collapse
-
.thread_key(mail) ⇒ Object
The thread root: References head, else In-Reply-To, else this Message-ID.
Instance Method Summary collapse
Class Method Details
.thread_key(mail) ⇒ Object
The thread root: References head, else In-Reply-To, else this Message-ID.
19 20 21 |
# File 'app/mailboxes/silas/agent_mailbox.rb', line 19 def self.thread_key(mail) (Array(mail.references).first || mail.in_reply_to || mail.).to_s end |
Instance Method Details
#process ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'app/mailboxes/silas/agent_mailbox.rb', line 8 def process channel_class.dispatch( thread_key: self.class.thread_key(mail), input: body_text, metadata: { "email" => { "from" => mail.from&.first, "subject" => mail.subject } } ) rescue Silas::TurnInProgressError # A reply arriving while a turn is active is dropped (v1 single-active-turn). end |