-
Notifications
You must be signed in to change notification settings - Fork 65
docs(station-login): add AI documentation - AGENTS.md and ARCHITECTURE.md #575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
3dfaaeb
3e5a754
0c71195
6379bd7
ca4c9bc
638da10
1b32e60
8b097a6
7286630
74b1bb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,327 @@ | ||
| # Station Login Widget | ||
|
|
||
| ## Overview | ||
|
|
||
| The Station Login widget provides a user interface for contact center agents to log in and out of their station. It handles device type selection (Extension, Mobile, Browser), team selection, and agent profile management. The widget integrates with the Webex Contact Center SDK and follows the standard three-layer architecture pattern (Widget → Hook → Component → Store). | ||
|
|
||
| **Package:** `@webex/cc-station-login` | ||
|
|
||
| **Version:** See [package.json](../package.json) | ||
|
|
||
| --- | ||
|
|
||
| ## Why and What is This Widget Used For? | ||
|
|
||
| ### Purpose | ||
|
|
||
| The Station Login widget enables contact center agents to: | ||
| - **Login to their station** with appropriate device settings | ||
| - **Select their team** from available teams | ||
| - **Choose device type** (Extension, Agent DN, Browser-based) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. For device type we use Desktop instead of Browser
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated |
||
| - **Logout from their station** when ending their shift | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, we can improve this |
||
| - **Update their profile settings** while logged in (profile mode) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This handles logout and login to another mode implicitly.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated |
||
| - **Handle multiple login scenarios** with continuation prompts | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't think this is possible
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed |
||
|
|
||
| ### Key Capabilities | ||
|
|
||
| - **Device Type Support**: Extension, Agent DN (Mobile), and Browser-based login | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, need to remove this '(Mobile)' as well
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated |
||
| - **Team Management**: Dropdown selection for multi-team agents | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| - **Profile Mode**: Update agent profile settings without full re-login | ||
| - **Error Handling**: Comprehensive error boundary with callback support | ||
| - **Multiple Login Detection**: Alerts and continuation flow for agents logged in elsewhere | ||
| - **Validation**: Dial number validation using regex patterns | ||
| - **Callbacks**: Extensible callbacks for login, logout, and sign-out events | ||
|
|
||
| --- | ||
|
|
||
| ## Examples and Use Cases | ||
|
|
||
| ### Getting Started | ||
|
|
||
| #### Basic Usage (React) | ||
|
|
||
| ```typescript | ||
| import { StationLogin } from '@webex/cc-station-login'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Import can be fixed. From external application all the imports are done from
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
| import React from 'react'; | ||
|
|
||
| function MyApp() { | ||
| const handleLogin = () => { | ||
| console.log('Agent logged in successfully'); | ||
| }; | ||
|
|
||
| const handleLogout = () => { | ||
| console.log('Agent logged out successfully'); | ||
| }; | ||
|
|
||
| const handleCCSignOut = () => { | ||
| console.log('Agent signed out from contact center'); | ||
| }; | ||
|
|
||
| return ( | ||
| <StationLogin | ||
| onLogin={handleLogin} | ||
| onLogout={handleLogout} | ||
| onCCSignOut={handleCCSignOut} | ||
| profileMode={false} | ||
| /> | ||
|
Comment on lines
+82
to
+88
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can add
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
| ); | ||
| } | ||
| ``` | ||
|
|
||
| #### Web Component Usage | ||
|
|
||
| ```html | ||
| <!-- Include the widget bundle --> | ||
| <script src="path/to/cc-widgets.js"></script> | ||
|
|
||
| <!-- Use the web component --> | ||
| <cc-station-login | ||
| profile-mode="false" | ||
| ></cc-station-login> | ||
|
|
||
| <script> | ||
| const widget = document.querySelector('cc-station-login'); | ||
|
|
||
| widget.addEventListener('login', () => { | ||
| console.log('Agent logged in'); | ||
| }); | ||
|
|
||
| widget.addEventListener('logout', () => { | ||
| console.log('Agent logged out'); | ||
| }); | ||
| </script> | ||
| ``` | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be removed. We no longer support web component. We should also remove |
||
|
|
||
| #### Profile Mode Usage | ||
|
|
||
| ```typescript | ||
| import { StationLogin } from '@webex/cc-station-login'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
|
||
| function AgentProfile() { | ||
| const handleSaveStart = () => { | ||
| console.log('Saving profile changes...'); | ||
| }; | ||
|
|
||
| const handleSaveEnd = (success: boolean) => { | ||
| if (success) { | ||
| console.log('Profile updated successfully'); | ||
| } else { | ||
| console.log('Profile update failed'); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <StationLogin | ||
| profileMode={true} | ||
| onSaveStart={handleSaveStart} | ||
| onSaveEnd={handleSaveEnd} | ||
| teamId="defaultTeamId" | ||
| doStationLogout={false} // Don't logout when signing out in profile mode | ||
| /> | ||
| ); | ||
| } | ||
| ``` | ||
|
|
||
| ### Common Use Cases | ||
|
|
||
| #### 1. Agent Login Flow | ||
|
|
||
| ```typescript | ||
| // Agent selects team, device type, and enters extension | ||
| // Widget handles the login process through the SDK | ||
| <StationLogin | ||
| onLogin={() => { | ||
| // Navigate to agent desktop | ||
| navigateToDesktop(); | ||
| }} | ||
| onLogout={() => { | ||
| // Return to login screen | ||
| navigateToLogin(); | ||
| }} | ||
| onCCSignOut={() => { | ||
| // Sign out from entire application | ||
| performFullSignOut(); | ||
| }} | ||
| profileMode={false} | ||
| /> | ||
| ``` | ||
|
|
||
| #### 2. Update Agent Profile Settings | ||
|
|
||
| ```typescript | ||
| // Agent updates device type or team while logged in | ||
| <StationLogin | ||
| profileMode={true} | ||
| onSaveStart={() => showSpinner()} | ||
| onSaveEnd={(success) => { | ||
| hideSpinner(); | ||
| showNotification(success ? 'Profile updated' : 'Update failed'); | ||
| }} | ||
| teamId={currentTeamId} | ||
| doStationLogout={false} | ||
| /> | ||
| ``` | ||
|
|
||
| #### 3. Handle Multiple Login Sessions | ||
|
|
||
| ```typescript | ||
| // Widget automatically detects if agent is logged in elsewhere | ||
| // Shows alert and provides continuation option | ||
| <StationLogin | ||
| onLogin={() => { | ||
| console.log('Successfully continued session'); | ||
| }} | ||
| // Widget handles the multiple login flow internally | ||
| /> | ||
| ``` | ||
|
Comment on lines
+163
to
+176
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should mention the config required for the multi login enabled or disabled
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is part of the store config not part of the StationLoginWidget. I will add it in the store's ai-docs
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this info be referenced here from the store's doc ? If that's helpful spec maybe we can add else not required
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a reference in the additional information below. We are avoiding to add links in the middle of the agents.md to avoid agents preemptively jumping to different docs and hallucinating. |
||
|
|
||
| #### 4. Custom Error Handling | ||
|
|
||
| ```typescript | ||
| import store from '@webex/cc-store'; | ||
|
|
||
| // Set error callback before rendering widget | ||
| store.onErrorCallback = (componentName, error) => { | ||
| console.error(`Error in ${componentName}:`, error); | ||
| // Send to error tracking service | ||
| trackError(componentName, error); | ||
| }; | ||
|
|
||
| // Widget will call this callback on errors | ||
| <StationLogin profileMode={false} /> | ||
| ``` | ||
|
Comment on lines
+178
to
+199
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if the error handling will be done at store level for the cc - @Shreyas281299
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to explain error handling here also, will add that
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added |
||
|
|
||
| ### Integration Patterns | ||
|
|
||
| #### With Custom Authentication | ||
|
|
||
| ```typescript | ||
| import { StationLogin } from '@webex/cc-station-login'; | ||
| import store from '@webex/cc-store'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All the imports are from
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right but this is also not incorrect, both are acceptable ways. But I will move the imports to @webex/cc-widgets
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, I wanted to discuss this. What would be the right way to document this so that it does not hallucinate |
||
|
|
||
| function AuthenticatedApp() { | ||
| // Initialize store with SDK instance | ||
| useEffect(() => { | ||
| const initializeCC = async () => { | ||
| // Initialize Contact Center SDK | ||
| const cc = await ContactCenter.init({ | ||
| token: authToken, | ||
| region: 'us1' | ||
| }); | ||
|
|
||
| // Set CC instance in store | ||
| store.setCC(cc); | ||
| }; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is nothing as such Please refer - https://developer.webex.com/webex-contact-center/docs/cc-web-widgets-quickstart
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for catching this
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated the sample code |
||
|
|
||
| initializeCC(); | ||
| }, [authToken]); | ||
|
|
||
| return <StationLogin profileMode={false} onLogin={handleLogin} />; | ||
| } | ||
| ``` | ||
|
|
||
| #### With State Management | ||
|
|
||
| ```typescript | ||
| import { StationLogin } from '@webex/cc-station-login'; | ||
| import { observer } from 'mobx-react-lite'; | ||
| import store from '@webex/cc-store'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated |
||
|
|
||
| // Observer component that reacts to store changes | ||
| const LoginContainer = observer(() => { | ||
| const { isAgentLoggedIn, teams, deviceType } = store; | ||
|
|
||
| if (isAgentLoggedIn) { | ||
| return <AgentDesktop />; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is incorrect, will fix this
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated sample code |
||
| } | ||
|
|
||
| return ( | ||
| <StationLogin | ||
| onLogin={() => { | ||
| // Store automatically updates isAgentLoggedIn | ||
| console.log('Teams available:', teams); | ||
| console.log('Device type:', deviceType); | ||
| }} | ||
| profileMode={false} | ||
| /> | ||
| ); | ||
| }); | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Dependencies | ||
|
|
||
| **Note:** For exact versions, see [package.json](../package.json) | ||
|
|
||
| ### Runtime Dependencies | ||
|
|
||
| | Package | Purpose | | ||
| |---------|---------| | ||
| | `@webex/cc-components` | React UI components | | ||
| | `@webex/cc-store` | MobX singleton store for state management | | ||
| | `mobx-react-lite` | React bindings for MobX | | ||
| | `react-error-boundary` | Error boundary implementation | | ||
|
|
||
| ### Peer Dependencies | ||
|
|
||
| | Package | Purpose | | ||
| |---------|---------| | ||
| | `react` | React framework | | ||
| | `react-dom` | React DOM rendering | | ||
| | `@momentum-ui/react-collaboration` | Momentum UI components | | ||
|
|
||
| ### Development Dependencies | ||
|
|
||
| Key development tools (see [package.json](../package.json) for versions): | ||
| - TypeScript | ||
| - Jest (testing) | ||
| - Webpack (bundling) | ||
| - ESLint (linting) | ||
|
|
||
| ### External SDK Dependency | ||
|
|
||
| The widget requires the **Webex Contact Center SDK** (`@webex/contact-center`) to be initialized and available through the store. The SDK provides: | ||
| - `stationLogin()` - Login to station | ||
| - `stationLogout()` - Logout from station | ||
| - `updateAgentProfile()` - Update agent profile settings | ||
| - `registerCC()` - Register contact center client | ||
| - `deregister()` - Deregister contact center client | ||
|
|
||
| --- | ||
|
|
||
| ## Props API | ||
|
|
||
| | Prop | Type | Required | Default | Description | | ||
| |------|------|----------|---------|-------------| | ||
| | `profileMode` | `boolean` | Yes | - | Shows save button (true) or login/logout (false) | | ||
| | `onLogin` | `() => void` | No | - | Callback when login succeeds | | ||
| | `onLogout` | `() => void` | No | - | Callback when logout succeeds | | ||
| | `onCCSignOut` | `() => void` | No | - | Callback when CC sign out is triggered | | ||
| | `onSaveStart` | `() => void` | No | - | Callback when profile save starts | | ||
| | `onSaveEnd` | `(success: boolean) => void` | No | - | Callback when profile save ends | | ||
| | `teamId` | `string` | No | - | Default team ID | | ||
| | `doStationLogout` | `boolean` | No | `true` | Perform station logout on CC sign out | | ||
|
Comment on lines
+301
to
+310
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please fix the default values where required
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated only profileMode was missing |
||
|
|
||
| --- | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| # Install as part of contact center widgets | ||
| yarn add @webex/cc-station-login | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't think we are allowing individual widgets to be installed
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can do this. Yes there are pre-requisite to this, but this is possible.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but will we ever use it this way ? if we document it like this Agent will write code referencing this so, please see if want to keep it like this.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated |
||
|
|
||
| # Or install the entire widgets bundle | ||
| yarn add @webex/cc-widgets | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should also mention npm
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated |
||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Additional Resources | ||
|
|
||
| For detailed component architecture, data flows, and sequence diagrams, see [architecture.md](./architecture.md). | ||
|
|
||
| --- | ||
|
|
||
| _Last Updated: 2025-11-26_ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Text could be improved and some fixes are required on the type of station login. Please refer this.
Also let's use
StationLoginas a single word everywhere in this file.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated