Third-party large model integration for intelligent outbound calls

Updated at:

Integration solution

image

API definition

To integrate, follow the four interface conventions below.

Function Compute proxies these APIs, primarily handling signature authentication and forwarding.

On the intelligent outbound bot page, configure the bot by following the process described below.

  • /proxy/beginSession: Begin session

    Description

    Starts a session.

    Protocol

    Server-Sent Events (SSE)

    Request parameters

    Parameter

    Type

    Required

    Example

    Description

    requestId

    String

    Yes

    UUID

    A unique ID for the request.

    tenantId

    Long

    Yes

    378210

    The tenant ID, which is your Alibaba Cloud UID.

    instanceId

    String

    Yes

    n1

    The instance ID.

    scriptId

    String

    Yes

    The scene ID.

    sessionId

    String

    Yes

    UUID

    The session ID.

    streamId

    String

    Yes

    UUID

    The dialog turn ID.

    vendorParams

    Map

    Yes

    Passthrough parameters.

    callingNumber

    String

    Yes

    The calling number.

    calledNumber

    String

    Yes

    The called number.

    Other fields

    String

    No

    Customer-defined passthrough fields.

    Response parameters

    Parameter

    Type

    Required

    Example

    Description

    requestId

    String

    Yes

    1

    The unique ID of the original request.

    httpStatusCode

    Int

    Yes

    200

    The HTTP status code.

    code

    String

    Yes

    OK

    The business response code. A value of 'OK' indicates success.

    message

    String

    No

    The error message that is returned if the request fails.

    data

    Object

    Yes

    streamEnd

    Boolean

    Yes

    Indicates whether the stream has ended.

    updatedTime

    Long

    Yes

    The time of the last update, in milliseconds.

    sessionId

    String

    No

    The session ID.

    streamId

    String

    No

    The dialog turn ID.

    answer

    String

    No

    The text of the bot's response.

    controlParamsList

    List<ControlParams>

    No

    A list of bot speech control parameters.

    type

    String

    Yes

    HangUp

    The control type.

    - HangUp: Disconnects the call.

    - Transfer: Transfers the call.

    - GatherDtmf: Collects DTMF input.

    - Voice: Plays a voice prompt.

  • /proxy/dialogue

    Description

    Manages conversational turns in a dialogue.

    Protocol

    SSE

    Request parameters

    Parameter

    Type

    Required

    Example

    Description

    requestId

    String

    Yes

    UUID

    The request ID.

    tenantId

    Long

    Yes

    231232121

    The tenant ID. This is the Alibaba Cloud UID.

    instanceId

    String

    Yes

    n1

    The instance ID.

    scriptId

    String

    Yes

    The script ID.

    sessionId

    String

    Yes

    UUID

    The session ID.

    streamId

    String

    Yes

    UUID

    The stream ID.

    utterance

    String

    Yes

    Check phone bill

    The user's utterance.

    extras

    List<Map>

    Additional data.

    dataType

    String

    DTMF

    The data type. Valid values: DTMF or Silence.

    dtmf

    String

    1234

    The DTMF digits.

    Response parameters

    Parameter

    Type

    Required

    Example

    Description

    requestId

    String

    Yes

    1

    The request ID.

    httpStatusCode

    Int

    Yes

    200

    The HTTP status code.

    code

    String

    Yes

    OK

    The response code.

    message

    String

    No

    The error message.

    data

    Object

    Yes

    streamEnd

    Boolean

    Yes

    Indicates whether the stream has ended.

    updatedTime

    Long

    Yes

    The update timestamp.

    sessionId

    String

    No

    The session ID.

    streamId

    String

    No

    The stream ID.

    answer

    String

    No

    The bot response.

    controlParamsList

    List<ControlParams>

    A list of control parameters.

    type

    String

    Yes

    HangUp

    The control type.

    - HangUp: Disconnects the call.

    - Transfer: Transfers the call.

    - GatherDtmf: Gathers DTMF input.

    - Voice: Plays a voice prompt.

  • /proxy/abortDialogue

    Description

    Aborts the current dialogue turn. This operation returns any text that has already been played and stops all subsequent actions.

    Protocol

    HTTPS

    Request parameters

    Parameter

    Type

    Required

    Example

    Description

    requestId

    String

    Yes

    UUID

    The request ID.

    tenantId

    Long

    Yes

    123232123

    The tenant ID. This is the Alibaba Cloud UID.

    instanceId

    String

    Yes

    n1

    The instance ID.

    scriptId

    String

    No

    The script ID.

    sessionId

    String

    Yes

    UUID

    The session ID.

    streamId

    String

    Yes

    UUID

    The stream ID.

    answer

    String

    No

    The text that was played before the interruption.

    type

    String

    Yes

    Canceled

    Canceled: The turn is canceled.

    Interrupted: The bot is interrupted.

    Response parameters

    Parameter

    Type

    Required

    Example

    Description

    requestId

    String

    Yes

    1

    The request ID.

    httpStatusCode

    Int

    Yes

    200

    The HTTP status code.

    code

    String

    Yes

    OK

    The response code.

    message

    String

    No

    The error message.

  • /proxy/endSession

    Description

    Ends the session.

    Protocol

    HTTPS

    Request parameters

    Parameter

    Type

    Required

    Example

    Description

    requestId

    String

    Yes

    UUID

    The request ID.

    tenantId

    Long

    Yes

    12321231

    The tenant ID. This is the Alibaba Cloud UID.

    instanceId

    String

    Yes

    n1

    The instance ID.

    scriptId

    String

    Yes

    The script ID.

    sessionId

    String

    Yes

    UUID

    The session ID.

    Response parameters

    Parameter

    Type

    Required

    Example

    Description

    requestId

    String

    Yes

    1

    The request ID.

    httpStatusCode

    Int

    Yes

    200

    The HTTP status code.

    code

    String

    Yes

    OK

    The response code.

    message

    String

    No

    The error message.

  • Common control parameters

    HangUpControlParams

    Parameter

    Type

    Required

    Example

    Description

    delay

    Int

    No

    0

    The hang-up delay in seconds. The default value is 0.

    Constraints: The value must be an integer from 0 to 10.

    reason

    String

    No

    The reason for hanging up.

    TransferControlParams

    Parameter

    Type

    Required

    Example

    Description

    transferType

    String

    Yes

    SkillGroup

    The transfer type.

    - SkillGroup: Transfers to a skill group.

    - Agent: Transfers to an agent (currently unsupported).

    - External: Transfers to an external number (currently unsupported).

    transferee

    String

    Yes

    skg-1234*****

    The transfer destination.

    transferor

    String

    No

    The transferor's phone number, which is required when transferring to an external number.

    DtmfControlParams

    Parameter

    Type

    Required

    Example

    Description

    terminator

    String

    Yes

    #

    The terminator for DTMF collection.

    Constraints: Only the # character is supported.

    maxDigits

    Int

    Yes

    The maximum number of digits to collect.

    Constraints: The value must be an integer from 1 to 100.

    timeout

    Int

    Yes

    The timeout, in seconds, between digit presses.

    Constraints: The value must be an integer from 1 to 10. A value of 5 is recommended.

    disableVoiceInput

    boolean

    No

    Specifies whether to disable voice input during DTMF collection.

    Default value: true.

    VoiceControlParams

    Parameter

    Type

    Required

    Example

    Description

    interruptible

    Boolean

    No

    false

    Specifies whether the bot's speech can be interrupted. The default value is false.

    silenceDetectionTimeout

    Int

    No

    The timeout, in seconds, for detecting user silence. The default value is 5.

    Constraints: The value must be an integer from 1 to 10. A value of 5 is recommended.

    synthesizerConfig

    Object

    No

    Parameters for controlling the bot's synthesized voice.

    The following providers are supported:

    • Alibaba Cloud small models

    • Alibaba Cloud CosyVoice large models

    • Doubao large models

    voice

    String

    Yes

    The voice for speech synthesis.

    For a list of available voices, refer to the documentation of the corresponding provider.

    volume

    Double

    No

    The speech volume. The default value is 50.

    For the supported value range, refer to the documentation of the corresponding provider.

    pitchRate

    Double

    No

    The pitch rate. The default value is 0.

    For the supported value range, refer to the documentation of the corresponding provider.

    speechRate

    Double

    No

    The speech rate. The default value is 0.

    For the supported value range, refer to the documentation of the corresponding provider.

Note

  1. Create a Function Compute instance in the China (Shanghai) region. This lets you use a private IP address to reduce network overhead. You can disable the public IP address for enhanced security.

  2. Each type of ControlParams has specific requirements:

    1. Voice: This parameter must be sent in the initial packet. It is ignored in subsequent packets.

    2. GatherDtmf: This parameter must be sent in the initial packet. It is ignored in subsequent packets.

    3. Transfer: This parameter can be sent at any time during the conversation.

    4. HangUp: This parameter can be sent at any time during the conversation.

  3. Although the beginSession interface is designed for streaming, it is currently implemented as a synchronous blocking call. Therefore, the API response time must be under 200 ms.

  4. To ensure a low-latency conversation, the large language model's time to first byte must be under 600 ms.

  5. Consider the following for text-to-speech (TTS) playback of the large language model's responses:

    1. Format numbers in the text output to ensure they are read correctly by the text-to-speech engine.

    2. Some text-to-speech engines may struggle with the intonation of words with multiple pronunciations.

Function Compute demo

chatbot-proxy.zip

Configuration procedure

Prerequisites

  1. Enable Function Compute.

  2. Enable Cloud Outbound Bot.

Function Compute

  1. Go to the Function Compute console: https://fcnext.console.aliyun.com/cn-shanghai/functions. In the top navigation bar, select China (Shanghai) as the region.

    image.png

  2. Create a Web function. This example uses a demo written in Java. The following figure shows the configuration:image.png

  3. Configure the function on its details page.

    1. In the trigger configuration, set the authentication method to signature method and enable the Disable public network access URL setting.

    2. Configure the Reserved Instance and horizontal scaling policies based on your business requirements. Set the number of Reserved Instances to at least 1 to prevent the first invocation from timing out.

  4. Obtain the Web function's configuration.

    1. Function name

    2. Function region

    3. Trigger address. To minimize invocation latency, use the internal access address (HTTP).

Configure Cloud Outbound Bot

  1. In large model scenario management, create a scenario and enter the function service parameters.image

  2. After creating the scenario, open it and configure the voice & VUI settings.image

  3. After completing the configuration, click voice debugging to run a test.image

  4. Return to the large model scenario list and click publish. Once published, you can use the scenario when creating a new outbound call task.

    image