Back to Auth0.ai
You are viewing use cases docs. Start a new chat to explore the demo.
Docs
Use case
Explained Prompt: Buy ZEKO if P/E ratio is above 15
Async Human in the Loop
Let your autonomous, async agents do work in the background. Request user permissions when needed.
Scenario
When the user requests to buy a specific company stock when its P/E ratio is above 15, the chatbot will monitor this metric and seek the user's approval (authorization) before executing any transaction.
This process is streamlined through Auth0, utilizing the CIBA (client-initiated backchannel authentication) flow to facilitate asynchronous user approval as needed. This ensures the user consents to the operation before any purchase order is executed.
How it works
- User Initiates Purchase Request: The user instructs the chatbot to monitor a specific company's stock, indicating a desire to purchase if the P/E ratio exceeds zero.
- Monitoring and Notification: Market0 continuously tracks the company's P/E ratio. When it rises above zero, the system notifies the user (using CIBA) to approve the purchase.
- User Confirmation: Upon notification, the user reviews the details and confirms whether to proceed with the transaction.
- Purchase Completion: Once the user approves, Market0 completes the purchase of 10 shares of the specified company.
Explore the code
To implement this functionality, we use several helper functions and components, detailed below.
1/**
2* Initiates an authentication request for the given user and scope.
3*
4* @param userId - The ID of the user to authenticate.
5* @param scope - The scope of the authentication request.
6* @returns An object containing the authentication request ID and the polling interval.
7*/
8const { authReqId, interval } = await startAuthenticationRequest(
9 userId,
10 scope
11);
12