> For the complete documentation index, see [llms.txt](https://bootcamp.shetechitaly.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bootcamp.shetechitaly.org/day2/02-10.md). Agents can also search and read this documentation through its [MCP server](https://bootcamp.shetechitaly.org/~gitbook/mcp).

# Step 10: auto refresh

> [How does `setInterval` work?](https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setInterval)

Since we want our timeline to be refreshed automatically, we'll use a native javascript function: `setInterval` that will handle this task. We pass the name of the function we want to be called (in our case `refreshMessages`) and the delay between each call expressed in milliseconds.

```javascript
setInterval(refreshMessages, 5000);
```
