Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@snapcall/agent-app-react

Package Overview
Dependencies
Maintainers
3
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@snapcall/agent-app-react

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

latest
Source
npmnpm
Version
1.5.0
Version published
Weekly downloads
1
-75%
Maintainers
3
Weekly downloads
 
Created
Source

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';

const App = () => (
  <AgentApp apiKey="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';

const RingingView = ({ answer, decline, callID }) => (
  <div>
    <p>A call is coming! (ID: {callID})</p>
    <button onClick={answer}>Answer</button>
    <button onClick={decline}>Decline</button>
  </div>
);

const InCallView = ({ hangUp, timer, Video }) => (
  <div>
    <Video timer={timer} />
    <button onClick={hangUp}>Hang up</button>
  </div>
);

const App = () => (
  <AgentApp
    apiKey="123"
    agentEmail="sauveur@snapcall.io"
    ringingView={RingingView}
    inCallView={InCallView}
    onClientLostConnection={() => console.log('The client lost the connection!!')}
  />
);

FAQs

Package last updated on 16 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts