Skip to content

Repository files navigation

SnapCall Agent App React

The SnapCall Agent App is a react component that will help you integrate SnapCall to receive calls.

This component is using the SnapCall widget API, and need a working react environment like this one.

Installation

npm install @snapcall/agent-app-react

Basic usage

import{AgentApp}from'@snapcall/agent-app-react';constApp=()=>(<AgentAppapiKey="123"agentEmail="sauveur@snapcall.io"/>);

Props

AgentApp

NameTypeDescription
apiKeystringYour SnapCall API key
agentEmailstringThe email of the agent receiving calls
snapcalljsUrl?stringA custom URL for the SnapCall Widget SDK script
onDisconnect?() => voidEvent triggered when the agent got disconnected
onReconnect?() => voidEvent triggered when the agent got reconnected
onClientLostConnection?() => voidEvent triggered when the client lost connection
onClientWeakNetwork?() => voidEvent triggered when the client network is weak
onAgentMicrophoneDown?() => voidEvent triggered when the agent microphone is down
onAgentMicrophoneUp?() => voidEvent triggered when the agent microphone is up
loadingView?() => ReactNodeView used for loading
waitingView?({ resetWrapUpTime: Function, wrapUpTimeLeft: number, startOutboundCall: Function, VideoPreview: ReactNode }) => ReactNodeView used when the agent is waiting for a call (ready)
ringingView?({ answer: Function, decline: Function, callID: string, VideoPreview: ReactNode }) => ReactNodeView used when the agent is receiving a call
inCallView?({ hangUp: Function, toggleHold: Function, timer: number, Video: ReactNode }) => ReactNodeView used when the agent is in call
errorView?({ error: string }) => ReactNodeView used when a blocking error occurs

Waiting view

Parameters available in the WaitingView component:

NameTypeDescription
resetWrapUpTime() => voidAlias for snapcallAPI.resetWrapUpTime
wrapUpTimeLeftnumberSeconds left until wrap up time is over
startOutboundCall({ phoneNumber: string }) => voidStart an outbound call on the provided phone number

Ringing view

Parameters available in the RingingView component:

NameTypeDescription
answer() => voidFunction to answer the call
decline() => voidFunction to decline the call
callIDstringThe ID of the ringing call

In Call View

Parameters available in the InCallView component:

NameTypeDescription
hangUp() => voidFunction to hang up the call
toggleHold() => voidFunction to put the call on hold or to resume it
timernumberSeconds since the call started
VideoReactNodeSee Video component details below

Video

The Video component is available as a props for the inCallView.

NameTypeDescription
timer?numberIf set, will display the call timer on top of the video element
hideControls?booleanWhether the control buttons should be displayed or not

Example

import{AgentApp}from'@snapcall/agent-app-react';constRingingView=({ answer, decline, callID })=>(<div><p>A call is coming! (ID: {callID})</p><buttononClick={answer}>Answer</button><buttononClick={decline}>Decline</button></div>);constInCallView=({ hangUp, timer, Video })=>(<div><Videotimer={timer}/><buttononClick={hangUp}>Hang up</button></div>);constApp=()=>(<AgentAppapiKey="123"agentEmail="sauveur@snapcall.io"ringingView={RingingView}inCallView={InCallView}onClientLostConnection={()=>console.log('The client lost the connection!!')}/>);

About

SnapCall AgentApp component for React

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages