Learn R Programming

aisdk (version 1.1.0)

FeishuChannelAdapter: Feishu Channel Adapter

Description

Transport adapter for Feishu/Lark event callbacks and text replies.

Arguments

Super class

aisdk::ChannelAdapter -> FeishuChannelAdapter

Methods


Method new()

Initialize the Feishu adapter.

Usage

FeishuChannelAdapter$new(
  app_id,
  app_secret,
  base_url = "https://open.feishu.cn",
  verification_token = NULL,
  encrypt_key = NULL,
  verify_signature = TRUE,
  send_text_fn = NULL,
  send_status_fn = NULL,
  download_resource_fn = NULL
)

Arguments

app_id

Feishu app id.

app_secret

Feishu app secret.

base_url

Feishu API base URL.

verification_token

Optional callback verification token.

encrypt_key

Optional event subscription encryption key.

verify_signature

Whether to validate Feishu callback signatures when applicable.

send_text_fn

Optional custom send function for tests or overrides.

send_status_fn

Optional custom status function for tests or overrides.

download_resource_fn

Optional custom downloader for inbound message resources.


Method parse_request()

Parse a Feishu callback request.

Usage

FeishuChannelAdapter$parse_request(headers = NULL, body = NULL, ...)

Arguments

headers

Request headers.

body

Raw JSON string or parsed list.

...

Unused.

Returns

Channel request result.


Method resolve_session_key()

Resolve a stable session key for a Feishu inbound message.

Usage

FeishuChannelAdapter$resolve_session_key(message, policy = list())

Arguments

message

Normalized inbound message.

policy

Session policy list.

Returns

Character scalar session key.


Method format_inbound_message()

Format a Feishu inbound message for a ChatSession.

Usage

FeishuChannelAdapter$format_inbound_message(message)

Arguments

message

Normalized inbound message.

Returns

Character scalar prompt.


Method prepare_inbound_message()

Prepare a Feishu inbound message using stored document context.

Usage

FeishuChannelAdapter$prepare_inbound_message(session, message)

Arguments

session

Current ChatSession.

message

Normalized inbound message.

Returns

Enriched inbound message.


Method send_text()

Send a final text reply to Feishu.

Usage

FeishuChannelAdapter$send_text(message, text, ...)

Arguments

message

Original normalized inbound message.

text

Final outbound text.

...

Unused.

Returns

Parsed API response.


Method send_status()

Send an intermediate status message to Feishu.

Usage

FeishuChannelAdapter$send_status(
  message,
  status = c("thinking", "working", "error"),
  text = NULL,
  ...
)

Arguments

message

Original normalized inbound message.

status

Status name.

text

Optional status text.

...

Unused.

Returns

Parsed API response or NULL.


Method send_attachment()

Send a generated local attachment to Feishu.

Usage

FeishuChannelAdapter$send_attachment(message, path, ...)

Arguments

message

Original normalized inbound message.

path

Absolute local file path.

...

Unused.

Returns

Parsed API response or NULL.


Method clone()

The objects of this class are cloneable with this method.

Usage

FeishuChannelAdapter$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.