Skip to main content

Limit off-topic questions with Jev

A sales agent should answer questions, but not forever: after 5 questions outside the sales flow, the lead gets the payment link instead of another answer — with no LLM call.
1

Create the contact attribute and the secret

Contacts → Attributes: add other_messages_count, a number. Settings → Secrets: add your OpenRouter key as OPENROUTER_API_KEY.
2

Ask Jev

A Run code step with the key jev. Jev is TypeSafe’s typed model on OpenRouter: it takes a state and typed questions, and returns a probability per question — cheap, and fast enough to run on every message.
A choice question can return the chat’s language in the same call, so the payment message is in Hindi, Tamil or English.
3

Route on the answer

A Condition: A code result · jev · action · equals · link → the payment link. Otherwise → Assign chat agent (your sales agent). Connect the Jev step’s Failure exit to the agent too, so a Jev outage changes nothing for the lead.
4

Send the link

A Run code step (key pay) that creates the link with your payments API and returns {"message": "Pay here: …"} — a stand-in link when x_context["is_test"] — then Send text {{pay.message}} and End.
If the agent has a question limit of its own in its prompt, remove it: the workflow is now the one counting.

Branch on button taps

Buttons are not branches: a tap is the user’s next message, with the button’s id. Put a Condition right after Start:

Photos and voice notes

Keep Image Context on when the agent reads images (payment screenshots, for example): the workflow’s own setting decides whether the image is kept for the agent.

Stay quiet on spam

A Condition: A count over the chat · Times the user sent this exact text · last 2 hours · is greater than · 2 → End. The third identical message gets no reply, and costs nothing.

A complete workflow to import

The Build with Claude skill ends with a complete workflow that uses every step type — buttons, a media rule, a spam counter, a classifier with a question limit, a template, a price list, a payment link and an assigned agent — ready to import and adapt.