Back to Auth0.ai
You are viewing use cases docs. Start a new chat to explore the demo.
Docs
Use case
Explained Prompt: Show me ZEKO upcoming events
Call APIs on users' behalf
Use secure standards to get API tokens for Google, Github and more... Seamlessly integrate your app with other products.
Scenario
When a user requests information about upcoming events for a company, such as ZEKO, the chatbot will retrieve and display a list of relevant events. Additionally, it will offer to check the user's availability in their Google Calendar to add reminders for selected events.
To check availability, integration with the Google Calendar API is necessary, with Auth0 handling user authentication and authorization for seamless access.
How it works
- Users Requests Upcoming Events: The user requests upcoming events for a specific company such as ZEKO.
- Displaying Events and Availability Check: Market0 handles the user's request and displays the list of upcoming events. As part of the response, it offers an option for the user to check their availability in Google Calendar.
- Third-Party Service Authorization: When the user clicks the "Check" button, Auth0 will handle the user's authorization to call the Google Calendar API on their behalf.
- API Call on Behalf of User: Once authorized, the app checks the user’s Google Calendar availability, allowing users to add event reminders to their schedule.
Explore the code
To implement this functionality, we use several helper functions and components, detailed below.
1<EnsureAPIAccess
2 //Configuration for the Provider
3 provider={{
4 name: "google",
5 api: "google-calendar",
6 requiredScopes: ["https://www.googleapis.com/auth/calendar.freebusy"],
7 }}
8 //Information shown in the widget
9 connectWidget={{
10 icon: (
11 <div className="bg-gray-200 p-3 rounded-lg flex-wrap">
12 <GoogleCalendarIcon />
13 </div>
14 ),
15 title: "Check your availability in Google Calendar",
16 description:
17 "This will only check free/busy availability, not get full calendar access. This showcases the Google Calendar API integration, while minimizing information disclosure necessary for a demo app.",
18 action: { label: "Check" },
19 }}
20 //Event triggered after succesful authorization
21 onUserAuthorized={onUserAuthorized}
22>
23 {/* children */}
24</EnsureAPIAccess>
1export async function checkAvailabilityForEvents(events: Event[]) {
2//Wraps a function that requires a google api access token:
3return withGoogleApi(async function (accessToken: string) {
4 return await Promise.all(
5 events.map(async (event: Event) => {
6 return checkAvailability(accessToken, event);
7 })
8 );
9});
10}