Skip to main content

API Methods

Once the widget is initialized, you can interact with it using the following methods:

createWidget(options)

Creates and initializes the phone widget with optional customization.

  • options (object, optional): Parameters for customizing the widget.
    • widgetContainerId (string, optional): A custom ID for the widget's container. Useful for applying specific styles or JavaScript manipulations.
    • widgetContainerStyle (object, optional): Custom CSS styles to apply to the widget's container. Accepts a React.CSSProperties object.
    • widgetId (string, optional): A custom ID for the widget itself.
    • widgetStyle (object, optional): Custom CSS styles to apply to the widget. Accepts a React.CSSProperties object.

startCall(params)

Starts a call to the specified number.

  • params (object, optional): Parameters for starting the call.
    • callTo (string, optional): The phone number to call. If not provided, it will use the number set in the last prepareCall call.
    • optionalData (object, optional): Additional call information.
      • contactExternalId (string, optional): External contact ID.
      • opportunityExternalId (string, optional): External opportunity ID.
      • analysisConfigId (string, optional): LlamadaPro analysis ID to choose how to analyze a call.
      • customParam1...N (string, optional): Custom parameters to add and store with the call.

You can send any number of custom parameters to link to the call. These will be stored alongside the new call and can be retrieved later using the API or webhooks.

prepareCall(params)

Prepares data for a future call without initiating it immediately.

  • params (object, optional): Parameters for preparing the call.
    • callTo (string, optional): The phone number to prepare for calling.
    • optionalData (object, optional): Additional call information (same as in startCall).

If called without parameters, it will clear any previously prepared call data.

Note: If a call is made to a different number than the prepared one, the prepared data is cleared. This ensures that the user calls the intended recipient when the display is unlocked. This behavior helps prevent accidental calls to unintended numbers.

enablePhoneNumberEditing(isEnabled)

Enables or disables the user's ability to edit the phone number in the widget.

  • isEnabled (boolean): If true, users can edit the phone number. If false, users cannot modify the phone number.

Use Case:

A common scenario for this function is after preparing a call using prepareCall(params). You might want to prevent the user from changing the phone number to ensure they call the intended recipient. By setting enablePhoneNumberEditing(false), the user can initiate the call by pressing the call button but cannot modify the phone number.

maximize()

Opens the phone widget.

minimize()

Closes the phone widget.

isOpen

Boolean indicating whether the widget is open.

isPhoneNumberEditable

Boolean indicating whether the phone number can be edited manually by the user in the widget. This property reflects the current state set by enablePhoneNumberEditing(isEnabled).

API Events

llapro_phonewidget_on_ready

Event triggered when the widget is fully loaded.

llapro_phonewidget_on_call_start

Event triggered when a call starts.

  • detail: Contains call data.
    • callTo (string): The phone number being called.
    • callDirection (string): Direction of the call (outgoing or incoming).
    • agentEmail (string): Email of the agent making the call.
    • optionalData (object): Additional call information provided during startCall or prepareCall.

Note: Depending on the type of call, the data available in the event detail may vary slightly. For example, the data from a bridge call might not contain agentEmail.

llapro_phonewidget_on_call_end

Event triggered when a call ends.

  • detail: Contains call data (same structure as llapro_phonewidget_on_call_start).

Note: This event will not trigger for bridge calls.