pub struct WhatsAppChannel { /* private fields */ }Expand description
§Runtime Negotiation
This Cloud API channel is automatically selected when phone_number_id is set in the config.
Use WhatsAppWebChannel (with session_path) for native Web mode.
Implementations§
Source§impl WhatsAppChannel
impl WhatsAppChannel
pub fn new( access_token: String, endpoint_id: String, verify_token: String, alias: impl Into<String>, peer_resolver: Arc<dyn Fn() -> Vec<String> + Sync + Send>, ) -> WhatsAppChannel
Sourcepub fn alias(&self) -> &str
pub fn alias(&self) -> &str
Return the alias under [channels.whatsapp.<alias>] that this
channel handle is bound to.
pub fn with_approval_timeout_secs(self, secs: u64) -> WhatsAppChannel
Sourcepub fn pending_approvals(
&self,
) -> &Arc<Mutex<HashMap<String, Sender<ChannelApprovalResponse>>>>
pub fn pending_approvals( &self, ) -> &Arc<Mutex<HashMap<String, Sender<ChannelApprovalResponse>>>>
Access the process-wide pending-approvals map shared across every
WhatsAppChannel instance. See [PENDING_APPROVALS] for why this
must be a static rather than per-instance.
Sourcepub fn with_proxy_url(self, proxy_url: Option<String>) -> WhatsAppChannel
pub fn with_proxy_url(self, proxy_url: Option<String>) -> WhatsAppChannel
Set a per-channel proxy URL that overrides the global proxy config.
Sourcepub fn with_dm_mention_patterns(self, patterns: Vec<String>) -> WhatsAppChannel
pub fn with_dm_mention_patterns(self, patterns: Vec<String>) -> WhatsAppChannel
Set mention patterns for DM mention gating. Each pattern string is compiled as a case-insensitive regex. Invalid patterns are logged and skipped.
Sourcepub fn with_group_mention_patterns(
self,
patterns: Vec<String>,
) -> WhatsAppChannel
pub fn with_group_mention_patterns( self, patterns: Vec<String>, ) -> WhatsAppChannel
Set mention patterns for group-chat mention gating. Each pattern string is compiled as a case-insensitive regex. Invalid patterns are logged and skipped.
Sourcepub fn compile_mention_patterns(patterns: &[String]) -> Vec<Regex>
pub fn compile_mention_patterns(patterns: &[String]) -> Vec<Regex>
Compile raw pattern strings into case-insensitive regexes. Invalid or excessively large patterns are logged and skipped.
Sourcepub fn text_matches_patterns(patterns: &[Regex], text: &str) -> bool
pub fn text_matches_patterns(patterns: &[Regex], text: &str) -> bool
Check whether text matches any pattern in the given slice.
Sourcepub fn apply_mention_gating(
dm_patterns: &[Regex],
group_patterns: &[Regex],
content: &str,
is_group: bool,
) -> Option<String>
pub fn apply_mention_gating( dm_patterns: &[Regex], group_patterns: &[Regex], content: &str, is_group: bool, ) -> Option<String>
Apply mention-pattern gating for a message.
Selects the appropriate pattern set based on is_group. When the
pattern set is non-empty, messages that do not match any pattern are
dropped (None); matched messages pass through unchanged. Empty
pattern sets always admit.
Sourcepub fn verify_token(&self) -> &str
pub fn verify_token(&self) -> &str
Get the verify token for webhook verification
Sourcepub fn parse_webhook_payload(&self, payload: &Value) -> Vec<ChannelMessage>
pub fn parse_webhook_payload(&self, payload: &Value) -> Vec<ChannelMessage>
Parse an incoming webhook payload from Meta and extract messages
Trait Implementations§
Source§impl Attributable for WhatsAppChannel
impl Attributable for WhatsAppChannel
Source§impl Channel for WhatsAppChannel
impl Channel for WhatsAppChannel
Source§fn send<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 SendMessage,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
WhatsAppChannel: 'async_trait,
fn send<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 SendMessage,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
WhatsAppChannel: 'async_trait,
Source§fn request_approval<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
recipient: &'life1 str,
request: &'life2 ChannelApprovalRequest,
) -> Pin<Box<dyn Future<Output = Result<Option<ChannelApprovalResponse>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
WhatsAppChannel: 'async_trait,
fn request_approval<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
recipient: &'life1 str,
request: &'life2 ChannelApprovalRequest,
) -> Pin<Box<dyn Future<Output = Result<Option<ChannelApprovalResponse>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
WhatsAppChannel: 'async_trait,
Source§fn listen<'life0, 'async_trait>(
&'life0 self,
_tx: Sender<ChannelMessage>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
WhatsAppChannel: 'async_trait,
fn listen<'life0, 'async_trait>(
&'life0 self,
_tx: Sender<ChannelMessage>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
WhatsAppChannel: 'async_trait,
Source§fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
'life0: 'async_trait,
WhatsAppChannel: 'async_trait,
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
'life0: 'async_trait,
WhatsAppChannel: 'async_trait,
Source§fn start_typing<'life0, 'life1, 'async_trait>(
&'life0 self,
_recipient: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn start_typing<'life0, 'life1, 'async_trait>(
&'life0 self,
_recipient: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Source§fn stop_typing<'life0, 'life1, 'async_trait>(
&'life0 self,
_recipient: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn stop_typing<'life0, 'life1, 'async_trait>(
&'life0 self,
_recipient: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Source§fn supports_draft_updates(&self) -> bool
fn supports_draft_updates(&self) -> bool
Source§fn self_addressed_mention(&self) -> Option<String>
fn self_addressed_mention(&self) -> Option<String>
<@1088...>,
Telegram presents @bot_username, Matrix presents
@bot:server, Slack wraps the user ID as <@U02...>. Returned
verbatim into the per-channel system prompt so the agent
recognizes its own mention without guessing, and uses the same
form to tag itself or peers in outbound replies. Read moreSource§fn drop_self_messages(&self, msg: &ChannelMessage) -> bool
fn drop_self_messages(&self, msg: &ChannelMessage) -> bool
Source§fn supports_multi_message_streaming(&self) -> bool
fn supports_multi_message_streaming(&self) -> bool
Source§fn multi_message_delay_ms(&self) -> u64
fn multi_message_delay_ms(&self) -> u64
Source§fn send_draft<'life0, 'life1, 'async_trait>(
&'life0 self,
_message: &'life1 SendMessage,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn send_draft<'life0, 'life1, 'async_trait>(
&'life0 self,
_message: &'life1 SendMessage,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Source§fn update_draft<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_recipient: &'life1 str,
_message_id: &'life2 str,
_text: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn update_draft<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_recipient: &'life1 str,
_message_id: &'life2 str,
_text: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
Source§fn update_draft_progress<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_recipient: &'life1 str,
_message_id: &'life2 str,
_text: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn update_draft_progress<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_recipient: &'life1 str,
_message_id: &'life2 str,
_text: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
Source§fn finalize_draft<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_recipient: &'life1 str,
_message_id: &'life2 str,
_text: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn finalize_draft<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_recipient: &'life1 str,
_message_id: &'life2 str,
_text: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
Source§fn cancel_draft<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_recipient: &'life1 str,
_message_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn cancel_draft<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_recipient: &'life1 str,
_message_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Source§fn add_reaction<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_channel_id: &'life1 str,
_message_id: &'life2 str,
_emoji: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn add_reaction<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_channel_id: &'life1 str,
_message_id: &'life2 str,
_emoji: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
Source§fn remove_reaction<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_channel_id: &'life1 str,
_message_id: &'life2 str,
_emoji: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn remove_reaction<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_channel_id: &'life1 str,
_message_id: &'life2 str,
_emoji: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
Source§fn pin_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_channel_id: &'life1 str,
_message_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn pin_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_channel_id: &'life1 str,
_message_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Source§fn unpin_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_channel_id: &'life1 str,
_message_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn unpin_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_channel_id: &'life1 str,
_message_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Source§fn redact_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_channel_id: &'life1 str,
_message_id: &'life2 str,
_reason: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn redact_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_channel_id: &'life1 str,
_message_id: &'life2 str,
_reason: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Source§fn request_choice<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_question: &'life1 str,
_choices: &'life2 [String],
_timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn request_choice<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_question: &'life1 str,
_choices: &'life2 [String],
_timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Source§fn supports_free_form_ask(&self) -> bool
fn supports_free_form_ask(&self) -> bool
ask_user
questions via the standard send + listen flow. Read moreAuto Trait Implementations§
impl Freeze for WhatsAppChannel
impl !RefUnwindSafe for WhatsAppChannel
impl Send for WhatsAppChannel
impl Sync for WhatsAppChannel
impl Unpin for WhatsAppChannel
impl UnsafeUnpin for WhatsAppChannel
impl !UnwindSafe for WhatsAppChannel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more