From Bright Pattern Documentation
Jump to: navigation, search
(Created page with "<translate> =startCall= Create a new phone call interaction. ==Request== ''Syntax'' {| class="wikitable" |startCall(phoneNumber: string, initialObject?: InteractionAssociat...")
 
(No difference)

Latest revision as of 13:53, 16 September 2022

• 5.19

startCall

Create a new phone call interaction.

Request

Syntax

startCall(phoneNumber: string, initialObject?: InteractionAssociatedObject): Promise<OperationResult<InitiateResult>>

Where:

type InteractionAssociatedObject = {

    id: string

    type: string

    displayName: string

    displayType: string

    customFields: Record<string, string>

}


type InitiateResult = {

    id: string | null

    error?: string

}

Parameters

Parameter Parameter Values Data Type Optional/Required Description
phoneNumber String Required The phone number to be dialed
initialObject Optional You can specify an object associated with this call on initialization. For example, on a click-to-call action from a contact, you can send info about that contact here.
id String The ID of the object to be associated with the the phoneNumber
type String The type of object  (e.g., contact, case, task, etc.)
displayName String The object’s display name
displayType String The object’s display type
customFields Record<string, string> Any additional information that you want to provide about the object

Example Request

    startCallButton.onclick = () => {

        const phone = startCallPhoneNumberInput.value

        let associatedObject: InteractionAssociatedObject | undefined = undefined

        const associatedObjectStr = associatedObjectTextarea.value

        if (associatedObjectStr) {

            try {

                associatedObject = JSON.parse(associatedObjectStr)

            } catch (e) {

                alert('You have syntax error in the associated object structure. Cannot parse JSON.')

                return

            }

        }

        adApi.startCall(phone, associatedObject)

    }

Return Value

Object Object Values Data Type Optional?

(Y/N)

Value Description
InitialResult
id String N Returns the created interaction ID. The ID can be used to track interaction updates with the callback onInteractionStateChange.

Note that this value can be null if interaction wasn’t created; a null result does not necessarily indicate an error

For example, with the “Deferred Dial” feature enabled, this API method will not start interaction, but only fill in the requested number in the Dialpad.

error String Returns an error message, if there was an error during the operation. The error is as follows:
  • Timeout error


< Previous | Next >