Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

AI Agents · Class

HumanMessage

HumanMessage represents a user's input in LangChain conversations. Create it with text or structured multimodal content and pass it to chat models or LangGraph state.

How it works

HumanMessage is the LangChain message type for representing input from a user. Construct one with text or structured content, then pass it to a chat model or graph as part of the conversation state.

Syntax

new HumanMessage(content)

Parameters

NameTypeDescription
contentstring | MessageContentThe user message content, supplied as text or structured multimodal content.

Returns

A HumanMessage instance representing a user-authored message.

Key points

  • HumanMessage identifies content as originating from the user.
  • The message exposes role, content, and response metadata fields shared by LangChain messages.
  • HumanMessage can carry text or multimodal content such as images, audio, and files.
  • In LangGraph.js, instantiate HumanMessage with a string when adding a user turn to graph state.

Common mistakes

  • A plain string input is automatically converted to a HumanMessage, so constructing one explicitly is optional when invoking a model with text.

Example: Create a HumanMessage

import { HumanMessage } from "@langchain/core/messages";

const message = new HumanMessage("What time is it?");
console.log(message.role);   // "user"
console.log(message.content); // "What time is it?"

Creates a user-authored message that can be included in a chat model's message array.

When to use it

Chat invocation

Send a user prompt to a chat model.

Graph messages

Seed or update a LangGraph conversation state.

Multimodal requests

Provide multimodal user input such as images or files.

  • AIMessage
  • SystemMessage
  • BaseMessage
  • StateGraph

Source: ChatOpenAI integration - Docs by LangChain. Checked 2026-10-15.