@avaya/infinity-agent-sdk - v1.0.0
    Preparing search index...

    Handling interactions

    This guide covers both directions of the interaction path - receiving inbound interactions (subscribing, accepting or rejecting, and auto-accept) and placing outbound voice interactions (selecting a routing queue, adding CRM context, and handling the returned interaction).

    Personas: Agent - receives incoming interactions and accepts or rejects them, and places outbound voice calls.

    Inbound interactions are delivered to the agent via the UserEventType.INTERACTION_RECEIVED event. The event payload carries the new Interaction, pre-populated with the customer, queue, and channel details your UI needs.

    Outbound interactions are agent-initiated. The returned interaction behaves identically to one delivered through the inbound path - the same interaction controls apply. Additional CRM context - case IDs, subject lines, screen-pop data - can be attached at creation time via the details parameter and travels with the interaction for the rest of its lifecycle.

    Subscribe to the UserEventType.INTERACTION_RECEIVED event to know when a new interaction is received:

    user.subscribe(UserEventType.INTERACTION_RECEIVED, (event) => {
    const interaction = event.payload.interaction;

    if (interaction.communicationType === InteractionCommType.PHONE) {
    showVoiceRingUI(interaction);
    }
    });

    Get the currently active interactions for an agent via User.getAssignedInteractions. This could come in handy in situations where you don't have an interaction object for example after a page reload.

    Accept an interaction via Interaction.accept. similarly, reject the interaction via Interaction.reject. Make sure to gate each action on its capability check:

    // Accept
    if (interaction.canAccept()) {
    await interaction.accept();
    }

    // Reject
    if (interaction.canReject()) {
    await interaction.reject();
    }

    Subscribe to the InteractionEventType.INTERACTION_ACCEPTED and InteractionEventType.INTERACTION_REJECTED events on the Interaction to know when the interaction is accepted or rejected respectively - these fire regardless who triggered the action, i.e. by your code or the interaction was auto-accepted:

    interaction.subscribe(InteractionEventType.INTERACTION_ACCEPTED, (event) => {
    if (event.payload.isAutoAccepted) {
    showAutoAcceptedBanner();
    }

    showInCallControls();
    });

    interaction.subscribe(InteractionEventType.INTERACTION_REJECTED, () => {
    clearIncomingInteraction();
    });

    When User.isInteractionAutoAcceptEnabled is true, the SDK accepts incoming interactions automatically without the agent's input. The InteractionEventType.INTERACTION_ACCEPTED event is still emitted, with InteractionAcceptedPayload.isAutoAccepted as true.

    If the auto-accepts fails due to any reason then UserEventType.INTERACTION_AUTO_ACCEPT_FAILED event is emitted.

    user.subscribe(UserEventType.INTERACTION_AUTO_ACCEPT_FAILED, (event) => {
    // SDK couldn't auto-accept - present the UI for manual action
    showAutoAcceptFailedBanner();
    });

    Pass the queue, destination phone number, and an optional details payload to User.createOutboundVoiceInteraction. The promise resolves to a new Interaction once the call is connected.

    Make sure the agent is logged in to the queue used for creating the outbound interaction. It is mandatory to provide queueId for non-hybrid agents while creating an outbound interaction.

    const queue = user.getAssignedQueues()[0];

    const interaction = await user.createOutboundVoiceInteraction({
    queueId: queue.queueId,
    phoneNumber: "+14155551234",
    });

    Make sure to gate User.createOutboundVoiceInteraction on User.canCreateOutboundVoiceInteraction.

    Note

    Elite agents: queueId is not required when user.isEliteVoiceEnabled is true. See Elite Outbound Calls.

    The optional details parameter of User.createOutboundVoiceInteraction accepts a subject line and arbitrary key/value customFields that persist on the interaction record:

    const interaction = await user.createOutboundVoiceInteraction({
    queueId: queue.queueId,
    phoneNumber: "+14155551234",
    details: {
    subject: "Order #A-7821 - refund follow-up",
    customFields: {
    crmCaseId: "C-12345",
    orderId: "A-7821",
    campaign: "Refund-Followup-Q2",
    },
    },
    });

    customFields are stored verbatim on the server. Updates to the customFields from other places (like CRM integration, by other agents etc.) are notified via InteractionEventType.INTERACTION_CUSTOM_FIELDS_UPDATED event on the interaction.

    Once User.createOutboundVoiceInteraction resolves, the returned Interaction is no different from the one received via the inbound interaction path:

    const interaction = await user.createOutboundVoiceInteraction({
    queueId: queue.queueId,
    phoneNumber: "+14155551234",
    });

    interaction.subscribe(InteractionEventType.INTERACTION_CALL_ESTABLISHED, () => {
    showInCallControls();
    });

    await interaction.holdCall();
    await interaction.resumeCall();
    await interaction.disconnectCall();
    await interaction.close(ResolutionStatus.RESOLVED);

    Elite (hybrid) agents route outbound calls through the Elite PBX dial plan rather than a cloud queue, so queueId is optional when User.isEliteVoiceEnabled is true:

    const interaction = await user.createOutboundVoiceInteraction({
    phoneNumber: "+14155551234",
    // queueId omitted - valid for Elite agents
    });

    Standard agents always require queueId. See Detecting Elite Context for how the deployment model is exposed at runtime.

    Failures surface as typed AvayaInfinityAgentSdkErrors with stable codes from AvayaInfinityAgentSdkErrorCodes. Errors that occur on the Interaction path belong to the ASE_4xxx family - match error.code against AvayaInfinityAgentSdkErrorCodes to identify the specific failure. If no specific code applies, the SDK falls back to ASE_4000.

    Call failures that occur after an outbound interaction is established don't reject createOutboundVoiceInteraction - they surface as InteractionEventType.INTERACTION_CALL_FAILED on the returned Interaction.