checkfor feature access, before allowing a user to do somethingtrackthe usage in Autumn afterwards (if needed)
This guide shows an asynchronous approach to checking and tracking. You can also check and reserve balance in a single, atomic API call for concurrent events.
Checking feature access
Check if a user has enough remaining balance of messages, before executing the action.feature_id used here is defined by you when you create the feature in Autumn.
Using React hooks to check access client-side
Using React hooks to check access client-side
When using React hooks, you have access to the
customer state, which contains all the billing data for your user (subscription status, feature permissions, usage balances, etc).You can use the client-side check function to gate features and show paywalls. Permissions are determined by reading the local customer state, so no call to Autumn’s API is made. The “true” state should always be fetched server-side.send-chat-message.tsx
Recording usage
After the user has successfully used a chatbot message, you can record the usage in Autumn. This will decrement the user’s message balance.Next steps Whenever your customers change their plan, they should automaticially have the correct access and limits. Next, display billing information to your customers.
Displaying Billing Data
Display plan, balance and usage information to your customers using Autumn’s
customer state
