Currency Converter Skill
Description
This skill allows the agent to convert currency amounts between different denominations (e.g., USD to EUR, GBP to JPY) using real-time exchange rates.
Tools
- •Exchange Rate API:
https://open.er-api.com/v6/latest/{BASE_CURRENCY}(Free, no key required). - •PowerShell: Used to fetch and parse JSON data.
Cross-Platform Method (Python)
Works on Windows, Linux, and Mac.
- •Run Script:
bash
# Usage: python convert.py <amount> <from> <to> python workspace/skills/currency/scripts/convert.py 100 USD EUR
Workflow (PowerShell Only)
- •
Fetch Rates:
- •Use
Invoke-RestMethodin PowerShell to get the latest rates for a base currency (default: USD).powershell$rates = Invoke-RestMethod "https://open.er-api.com/v6/latest/USD"
- •Use
- •
Calculate:
- •Get the rate for the target currency (e.g., EUR).
- •Multiply the amount by the rate.
powershell
$amount = 100 $targetRate = $rates.rates.EUR $result = $amount * $targetRate Write-Output "100 USD = $result EUR"
- •
Example Command:
- •To convert 50 USD to GBP:
powershell
$r = Invoke-RestMethod "https://open.er-api.com/v6/latest/USD"; $r.rates.GBP * 50
- •To convert 50 USD to GBP:
Supported Currencies
- •Common: USD, EUR, GBP, JPY, CAD, AUD, CHF, CNY, INR, etc.
- •The API returns 160+ currencies.