Retrieves chat history from an external chat backend via the JSON-RPC 2.0
WebSocket services.chat_client.get_chat_history. Complements chatSend for
workflows that need to read a conversation from a remote chat host.
Inputs (handles)
Handle
Connection type
Required
Purpose
input-main
main
no
Upstream payload; template variables can populate params
flowchart TD
A[Receive params] --> B[Call services.chat_client.get_chat_history]
B -- JSON-RPC error --> E[Return error envelope]
B -- RPC ok --> F{result.success?}
F -- false --> E
F -- true --> G[Wrap result.messages + count into ChatHistoryOutput]
Decision Logic
Validation: none; no parameter is required.
Branches: success vs error branch on RPC response success flag.
Fallbacks: host/port/session_id/api_key/limit all have defaults.
Error paths: not result.success raises RuntimeError(result.error or "chatHistory fetch failed");
BaseNode.execute() wraps the raised exception into the standard error envelope
(success=false, error, plus full traceback at logger.exception for non-NodeUserError).
Side Effects
Database writes: none.
Broadcasts: none.
External API calls: JSON-RPC 2.0 WebSocket to ws://<host>:<port> via
services.chat_client.get_chat_history.
File I/O: none.
Subprocess: none.
External Dependencies
Credentials: optional api_key parameter, not looked up via
auth_service.
Services: external chat backend speaking the project chat JSON-RPC
protocol.
Any exception from get_chat_history is swallowed and surfaced as
success=false. No retry.
port and limit are coerced via int(); non-numeric strings raise
ValueError and surface as success=false.
The handler returns {"messages": ...} using result.get('messages', [])
from the RPC. If the chat backend returns messages nested under another key,
they will be dropped silently (returned as empty list).
Related
Skills using this as a tool: none.
Other nodes that consume this output: any node templating
{{chatHistory.messages}}.