# History

During each interaction with your agent, `carter-js` will log the interaction to the Carter Object's `history` property. This property stores an array of all the interactions with your Carter agent while your program is running, the most recent being at the start of the array. You can access these in a couple of ways.

<pre class="language-javascript"><code class="lang-javascript">// Assuming you have created a Carter object called carter

// Access the latest interaction
<strong>const lastInteraction = carter.history[0]
</strong>// OR
const lastInteraction = carter.latest()

// Access a specific entry
const interaction = carter.history[7]

// Loop through interactions and log the results
for (const interactions of carter.history) {
    console.log(interaction.payload.query)
    console.log(interaction.data.output.text)
}
</code></pre>

`carter-js` will not log an interaction in history if it is unsuccessful.

## Conversation Entries

The `Carter.history` array stores an array of `ConversationEntry` objects.

```javascript
ConversationEntry {
    isoTimestamp,
    interaction
}
```

**isoTimestamp:** A timestamp string in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.

**interaction:** An interaction object.
