Retrieves the content of the most recent user message from a client's session history.
This function fetches the raw history for a specified client using getRawHistory and finds the last entry where the role is "user" and the mode
is "user". It is wrapped in beginContext for a clean execution environment and logs the operation if enabled via GLOBAL_CONFIG. The result is
the content of the last user message as a string, or null if no matching user message exists in the history.
Parameters
clientId: string
The unique identifier of the client session whose last user message is to be retrieved.
Returns Promise<string>
A promise that resolves to the content of the last user message, or null if none is found.
Throws
If getRawHistory fails due to session validation or history retrieval issues.
Example
constlastMessage = awaitgetLastUserMessage("client-123"); console.log(lastMessage); // Outputs the last user message or null
Retrieves the content of the most recent user message from a client's session history.
This function fetches the raw history for a specified client using
getRawHistory
and finds the last entry where the role is "user" and the mode is "user". It is wrapped inbeginContext
for a clean execution environment and logs the operation if enabled viaGLOBAL_CONFIG
. The result is the content of the last user message as a string, ornull
if no matching user message exists in the history.