Chat / Platform API
Current version: v3
    Chat Platform API v3
    Chat Platform API
    Chat
    Platform API
    Home
    /
    Chat
    /
    Platform API
    /
    Message

    Translate a message into other languages

    Translates a message into specific languages. Translation only works for text messages, whose type is MESG.

    Note: Message translation is powered by Google Cloud Translation API recognition engine. Find language codes supported by the translation engine or visit the Language Support page in Google Cloud Translation.


    HTTP request

    POST https://api-{application_id}.sendbird.com/v3/{channel_type}/{channel_url}/messages/{message_id}/translation
    

    Parameters

    The following table lists the parameters that this action supports.

    Required
    Parameter nameTypeDescription

    channel_type

    string

    Specifies the type of the channel. Acceptable values are open_channels and group_channels.

    channel_url

    string

    Specifies the URL of the target channel.

    message_id

    long

    Specifies the unique ID of the message to translate.


    Request body

    The following table lists the properties of an HTTP request that this action supports.

    Required
    Property nameTypeDescription

    target_langs

    array of strings

    Specifies an array of one or more codes of languages to translate the message.

    {
        "target_langs": ["es", "de"]    // Spanish and German
    }
    

    Response

    If successful, this action returns a message resource in the response body.

    {
        "message_id": 273779321,
        "type": "MESG",     // File and admin messages aren't supported by the message auto-translation feature.
        "custom_type": "",
        "channel_url": "sendbird_group_channel_6037267_600ddc81a5e23049c804193370d47217fa2ed5f9",
        "user": {
            "user_id": "Julia",
            "nickname": "Yogini",
            "profile_url": "https://sendbird.com/main/img/profiles/profile_94_512px.png",
            "metadata": {
                "location": "Bali",
                "marriage": "N"
            }
        },
        "mention_type": "users",
        "mentioned_users": [],
        "is_removed": false,
        "message": "Hi, nice to meet you!",
        "translations": {   // The message has been translated into the specified languages.
            "es": "¡Hola, encantado de conocerte!",     // Spanish
            "de": "Hallo, schön, Sie zu treffen!"       // German
        },
        "data": "",
        "created_at": 1544810640267,
        "updated_at": 0,
        "file": {}
    }
    

    In the case of an error, an error object is returned. A detailed list of error codes is available here.