Skip to main content

Two ways to read the conversation: prevMessage and history(start, end)

When you design a chat workflow, Asgard gives you two common ways to read what the user has said: prevMessage and history(start, end). Both read the conversation, but they suit different situations and differ in how flexible they are.

🔹 prevMessage​

  • What it does: returns the previous message
  • Simple syntax and easy to use, which suits a single-turn exchange
  • Typical use:
prevMessage
  • Where it fits:
    • An echo bot replying with the previous message
    • A quick response to a single command or a one-turn query

🔸 history(start, end)​

  • What it does: returns the whole conversation history, or a section of it
  • Flexible syntax, with a start and an end position, which suits multi-turn conversations and reasoning over context
  • Example:
// the full history
history(0, -1)

// the last three messages
history(-3, -1)
  • Where it fits:
    • An LLM chatbot whose answer depends on the context
    • Multi-turn interaction, tasks that need memory, summarising, analysis