Do it yourself
#- Check that the app has AI: see Add AI to your app.
- Open the chat that a new Cloud app has: the
/chatpage, with its backend at/api/ai/chat/. Its agent is inbackend-nest/src/ai/examples/booking-agent/. Change the agent's instructions and tools for your app. Each part in code: Build a chat with the SDK. - Mark each tool that the user confirms with
approval: true. The chat then shows the user Approve and Deny before the tool runs. - For an action only you allow, such as a refund, do not use
approval: true: the person in the chat would approve it. Let the tool save a request, and approve requests on an admin page of your app. The Leads page of a new Cloud app is an example of an admin page. - Set the daily limit per user in the chat's controller:
limits: { user: { creditsPerDay: 1 } }. - Send one message on the page, and approve one action, in the chat or on your admin page. In Settings, Usage, the project's AI Gateway row counts the requests.
What each user costs
#Ask the agent what your app's AI cost per user, per model or per day. It reads your app's usage from Playcode. Your app tells Playcode which of its users each request is for; the requests without a user are counted together.
If it doesn't work
#The chat says the daily limit is reached
#The user spent the credits of their day. The limit opens again at 00:00 UTC. Raise creditsPerDay if it is too low for your users.
An action waits and nothing happens
#An action that the user confirms waits for that user: in their conversation, they choose Approve or Deny. A request that waits for you is on your admin page.
Sending a message answers 409
#The conversation has an answer in progress, or an action that waits for approval. Wait for the answer, or approve, deny or stop it first.
Limits
#- The chat needs a Cloud app. A static site has no server for its conversations.
- A user's conversations are theirs: another user cannot open them.
- The daily limit is counted per user. Two answers of one user at the same moment can pass it by one model call each.