Canadian mortgage tool. Handles BOTH numeric payment calculations AND current rate lookups. Pick the operation with the required `intent` field; every other field belongs to exactly one intent and is ignored by the others.
CHOOSE `intent` FIRST:
- intent='rates' — the user wants to KNOW a rate. No other input is needed or accepted.
- intent='payment' — the user wants a payment NUMBER computed. Requires loanAmount, paymentFrequency, amortization, rateType, rateTerm.
Never route a Canadian mortgage rate or payment question to the knowledge base. This tool owns both. The knowledge base holds no rate table and no calculator, so sending a rate or payment question there produces an ungrounded answer.
=== intent='rates' ===
Returns Rifo's current best Canadian mortgage rates (fixed and variable, across the published rate-lock terms) with the offering lender. Takes NO other input — do not send loanAmount, rateTerm, rateType, or any calculator field with this intent; the response is the full published table and the caller picks from it.
Use for:
- 'what are today's best mortgage rates'
- 'current 5-year fixed rate' / 'what's the 3-year fixed right now'
- 'how low is the variable rate' / 'what variable rate can I get'
- 'what rate is Rifo offering'
- any bare rate lookup with no loan amount and no request for a payment number.
The result carries every published term, so answer a question about one specific term by reading that term out of the returned table — do not call again. After a successful call, present the returned rates plainly (term, fixed/variable, rate, lender) and do not invent rates the result does not contain.
=== intent='payment' ===
Returns per-period payment plus interest/principal breakdowns over the rate-lock term and full amortization, and optionally a yearly amortization table.
PRIMARY TRIGGER PHRASES:
- 'what would my monthly/bi-weekly/weekly payment be on a $X mortgage...'
- 'payment on a $X mortgage, N-year fixed/variable, M-year amortization'
- 'what am I looking at per payment' (with loan amount or home price + down payment given)
- 'if I locked in R% on a $X mortgage... what does that come out to'
- 'what does it look like if I [add a lump sum / increase payment / prepay]' with loan amount given → use lumpsumPrepayment / paymentIncrease / annualPrepayment
- 'show me the year-by-year breakdown' or 'show me the amortization table' with loan amount given → set generateAmortizationTable=true
- any message that supplies enough of {loanAmount or homePrice+downPayment, paymentFrequency, amortization, rateType, rateTerm} to run a calculation.
If the user supplies a loan amount, home price + down payment, an amortization period, a rate-lock term, or a payment frequency together with intent to know a payment number, use intent='payment' — do NOT route to the knowledge base just because the message also contains words like 'mortgage', 'fixed', 'variable', or 'rate'.
Required inputs for this intent: loanAmount, paymentFrequency, amortization, rateType, rateTerm. Infer from natural language; only ask about fields you cannot infer:
- '$X mortgage' -> loanAmount.
- If the user gives a home price and down payment instead of a mortgage amount, calculate loanAmount = homePrice - downPayment before calling the tool.
- 'monthly'/'bi-weekly'/'weekly'/'semi-monthly' -> paymentFrequency. 'accelerated' prefix -> acc-bi-weekly or acc-weekly.
- 'N-year amortization' or 'amortized over N years' -> amortization = N*12 months.
- 'N-year fixed' or 'N-year variable' -> rateType + rateTerm = N*12 months. rateTerm MUST be a multiple of 12.
Do NOT ask the user for `rate`. Omit it and the tool auto-resolves the appropriate rate; the value used appears in inputs.rate (do not explain its source to the user). Pass `rate` ONLY when the user spontaneously provides one (e.g. 'use 6%', 'what if 5.25%?', 'I locked in 4.79'). If the user wants to see the rate table itself rather than a payment, that is intent='rates', not a payment call.
After a successful call, summarize only the returned calculation and explain returned fields only as needed to read the result. Do not add mortgage advice or broader educational content.
=== OUT OF SCOPE FOR EVERY INTENT ===
This tool computes Canadian payments and returns Canadian rates. It cannot decide anything about a particular borrower.
Four questions are a RIFO agent's, not yours: (1) whether a mortgage would be approved, what income qualifies, or whether the user can afford one -- including self-employed or unstable-income cases, and pre-approval odds; (2) which rate type, term, amortization, or lender the user should pick; (3) any mortgage outside Canada, because this formula is Canadian and would be wrong elsewhere; (4) whether to break, refinance, or renew a mortgage, and what the penalty would be.
For these, do NOT answer from your own knowledge and do NOT ask the user for figures so you can work it out -- collecting income, debts, or credit to assess them is the same act as deciding them. Say in one or two sentences that a RIFO agent handles it and why, then ASK whether to put them in touch and stop there. Do not call `contact_agent` on this turn: opening a form nobody asked for is its own failure, and that tool is for users who have said yes. Call it on the next turn once they accept, or immediately if they had already asked for an agent -- in that case open the form without giving a verdict first. Adding a caveat does not make an out-of-scope answer acceptable.
Still fine after that hand-off: computing a payment for any amount they name with intent='payment', and showing Rifo's published rates with intent='rates'. Rifo publishes advertised tiers, never personalized quotes.
=== ERRORS ===
On isError=true, branch on structuredContent.errorCode:
- VALIDATION_ERROR: re-collect the offending input and retry. A missing required field for intent='payment' reports itself this way.
- RATE_UNAVAILABLE / RATE_NOT_PUBLISHED: tell the user Rifo's best rate for that specific rate type and term isn't available, then offer two choices — (1) use a rate they've been quoted, or (2) use a 5% placeholder for a ballpark estimate. Do not ask them to invent a number. Retry with `rate` set once they choose.
- BENDIGI_API_ERROR: report and stop.
If the user changes any calculation input, call again with updated values.