InfinityElement API for web components to interact with the Infinity Extensibility Framework
npm install @avaya/infinity-elements-api
Element API for InfinityElements to interact with the Infinity Extensibility Framework. This library provides a robust interface for communication between web components and the Infinity Agent Desktop.
- Installation
- Features
- Quick Start
- Basic Setup
- React Example
- Core Concepts
- ElementAPI
- API Documentation
- Development
- Documentation Generation
- License
- Related Packages
- Support
``bash`
npm install @avaya/infinity-elements-api
- š Easy Integration - Simple API for web components to interact with core-agent-ui
- š” Event-Driven - Subscribe to interaction events (accepted, ended, status changes)
- šÆ Type-Safe - Full TypeScript support with comprehensive type definitions
- š Call Management - Complete call control (transfer, consult, hold, mute, etc.)
- š¤ Agent Management - Get/set agent status, access user information
- š¬ Messaging - Send rich media messages and interact with the chat feed
`typescript
import { ElementAPI } from "@avaya/infinity-elements-api";
// Create API instance
const api = new ElementAPI();
// Get user information
const userInfo = await api.getUserInfo();
console.log("Agent:", userInfo.displayName);
console.log("Status:", userInfo.agentStatus);
// Listen for interaction events
api.onInteractionAccepted((interactionId) => {
console.log("Interaction accepted:", interactionId);
});
api.onInteractionEnded((interactionId) => {
console.log("Interaction ended:", interactionId);
});
// Don't forget to clean up!
// In React: useEffect cleanup, in plain JS: on element unmount
api.destroy();
`
`typescript
import { ElementAPI } from "@avaya/infinity-elements-api";
import { useEffect, useState } from "react";
function MyElement() {
const [userInfo, setUserInfo] = useState(null);
useEffect(() => {
const api = new ElementAPI();
// Fetch user info on mount
api.getUserInfo().then(setUserInfo);
// Subscribe to interaction events
const unsubscribe = api.onInteractionAccepted((interactionId) => {
console.log("Interaction accepted:", interactionId);
});
// Cleanup on unmount
return () => {
unsubscribe();
api.destroy();
};
}, [api]);
return (
Status: {userInfo?.agentStatus}
Core Concepts
$3
The main class for interacting with the Infinity Extensibility Framework. It handles:
- API requests to core-agent-ui via
window.postMessage
- Event subscriptions for interaction lifecycle
- Inter-element communication via the host (postMessage)API Documentation
For complete API documentation with detailed method signatures, parameters, and return types, see:
š Full API Reference - See
API.md included in this package (/@avaya/infinity-elements-api/API.md)Development
`bash
Install dependencies
npm installBuild the library
npm run buildRun tests
npm testWatch mode for tests
npm run test:watchGenerate documentation
npm run docsLint
npm run lint
`Documentation Generation
This package uses TypeDoc to automatically generate documentation from source code:
`bash
Generate docs (output to docs/api/)
npm run docsWatch mode for live documentation updates
npm run docs:watch
`The documentation is automatically generated from JSDoc comments in the source code, ensuring it stays in sync with the implementation.
License
MIT
Related Packages
@avaya/infinity-elements-sdk - CLI tool for scaffolding InfinityElement projectsSupport
For the complete API documentation, see
API.md included in this package (/@avaya/infinity-elements-api/API.md`).