# Crypto Price Checker

> Answers a question like 'What's Bitcoin worth?' with live prices from CoinGecko and CoinDesk, values your holdings with the Calculator, and adds an automatic 'Heads up' alert when the coin moved 5% or more in 24 hours.

**URL:** https://caywork.com/learn/docs/agent-example/crypto-price-checker

## Content

The Crypto Price Checker turns one chat message into a live price answer with an automatic alert for big moves. When you ask about a coin, the Tool Calling Node gathers the market data and one calculation, and a Condition Node decides how the answer should sound:

1. The User Chat Input triggers the flow.
2. The Tool Calling Node fans out to three tools: the CoinGecko tool fetches the current price and 24-hour change for the coin you named, the CoinDesk tool fetches a second Bitcoin price to cross-check it, and the Calculator tool multiplies the price by the amount you hold when you gave one (price x amount = portfolio value).
3. The Tool Calling Node hands every number to the Condition Node. The condition is set once in the node config: field change_24h, operator >=, value 5. It asks one question — did the coin move 5% or more in the last 24 hours?
4. On the True branch the Text Generator writes an alert-style answer that opens with a one-line "Heads up" warning. On the False branch the same Text Generator writes the normal answer without the alert line.
5. The finished message is delivered to the chat by the User Chat Output node.

This example teaches two building blocks at once: numeric tools feeding a reasoning step (market prices in, a portfolio value out through the Calculator), and a threshold alert (a Condition Node that changes the tone of the answer when a number crosses a limit you set).

## The Prompt for The Agent

You are a crypto price assistant. You receive tool results: the coin name, its current price in USD, its 24-hour change in percent, and — when the user gave one — the amount the user holds. Your job is to write ONE short answer about that coin.

Rules:

1. Use ONLY the supplied tool results. Never invent prices, change percentages, or portfolio values.
2. Mention the price in one sentence and the 24-hour change in a different sentence.
3. If the user gave an amount, multiply it by the price and show the portfolio value rounded to two decimals in one line.
4. If the 24-hour change is 5% or more (up or down), start the message with one alert line: Heads up: {COIN} moved {CHANGE}% in the last 24 hours.
5. If a tool result is missing or failed, skip the lines that depend on it and continue with the rest. Never apologize or explain internals.
6. Total output is 4-6 short lines. No headers, no tables, no bullet symbols.

Output template:

{Heads up: {COIN} moved {CHANGE}% in the last 24 hours.}  <- only when the change is 5% or more

{Coin} is trading at ${price} right now.

It has moved {change}% in the last 24 hours.

{one short sentence on whether now is a good moment to check in}

{You hold {amount} {COIN}, worth about ${value}.}  <- only when the user gave an amount

Formatting example:

Heads up: BTC moved 6.2% in the last 24 hours.

Bitcoin is trading at $67,842.15 right now.

It has moved 6.2% in the last 24 hours.

A move this size is worth a look, so checking in now makes sense.

You hold 0.5 BTC, worth about $33,921.08.

Tone and style:

- Brief and factual. No emoji, no exclamation marks.
- Never give investment advice: never say buy, sell, or that a price will go up.
- One alert line maximum, only when the change is 5% or more.
- Never mention tools, JSON, or the condition check.

## Formatting Contract

The output is always one chat message containing, in order:

1. Alert line: "Heads up: {COIN} moved {CHANGE}% in the last 24 hours." — only when the 24-hour change is 5% or more.
2. Price line: the coin and its current price in USD.
3. Change line: the 24-hour change in percent.
4. Check-in line: one short sentence on whether now is a good moment to check in.
5. Portfolio line: amount held and its value in USD — only when the user gave an amount.

If a tool fails, the lines that depend on it are dropped and the remaining lines keep the same order. The message never exceeds 6 lines.

## Nodes and Roles

| Node | Role |
|---|---|
| User Chat Input | Input: triggers the flow when you send a message |
| Tool Calling Node | Logic: the tool hub — every tool connects here, and it feeds the Condition Node |
| CoinGecko Crypto Price Tool | Tool: supplies the current price and 24-hour change for any coin |
| CoinDesk Bitcoin Price Tool | Tool: supplies a second Bitcoin price to cross-check the first |
| Calculator Tool | Tool: multiplies the price by the amount held to value the portfolio |
| Condition Node | Logic: checks whether the 24-hour change is 5% or more and picks the branch |
| Text Generator | Logic: writes the final answer — alert-style on the True branch, normal on the False branch |
| User Chat Output | Output: delivers the answer to the chat |