beginnerChatClient, Messages & Prompts

What's the difference between a system message and a user message in a chat prompt?

The system message sets persistent behavior/persona/constraints for the whole conversation (e.g. 'You are a customer support agent, only answer questions about billing') and is typically not shown to the end user. The user message is the actual per-turn input from whoever is chatting — mixing instructions into user messages instead of the system message makes them easy for a user to override or ignore in later turns.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to Why does prompt structure (using a template with placeholders) matter more as an app scales past a demo?← Back to all Spring AI questions