LogoLogo
ALO.ai
Developer Documentation
Developer Documentation
  • Developer Documentation
  • Developer Account
    • API Key
  • SDKs
    • Authentication
    • Chat
      • Configuration
      • Send Messages
        • Upload Files
      • Message History
      • Message Actions
      • Message Counts
      • Translation
      • Typing Indicators
      • API Reference
        • Event
        • Message
    • Presence
      • Configuration
      • Basic Usage
      • Methods
    • Audio
      • Prerequisites
      • Instantiating Audio Service
      • Connect to a Channel
      • Disconnecting Audio Service
      • Push To Talk (PTT)
      • Full Duplex
      • Mute and Unmute Audio
      • Input/Output Device Selection
        • Microphone Selection
        • Speaker Selection
      • Channel Participants
      • Text To Speech Audio (TTS)
      • Automatic Reconnects
      • Handling Events
      • Classes
        • AloAudio
        • AudioUser
        • AudioChannel
        • Participant
    • Video
      • Prerequisites
      • Instantiating Video Service
      • Connect to a Channel
      • Disconnecting Video Service
      • Input Device Selection
        • Microphone Selection
        • Camera Selection
      • Publishing Streams
      • Modifying Published Streams
      • Channel Participants
      • Rendering Streams
        • Local Stream
        • Remote Streams
      • Muting/Unmuting Remote Streams
      • Recording Video (coming soon)
      • Automatic Reconnects
      • Handling Events
      • Classes
        • AloVideo
        • Participant
        • VideoChannel
        • VideoUser
  • ALO APPS
    • Overview
    • Creating Apps
    • Webhooks
      • Verifying Requests from ALO
    • Custom Action Forms
    • Using the ALO Platform API
  • ALO Platform API
    • Overview
    • Authentication
    • API
      • Actions and Periods
      • Channels
      • Channel Messages
      • Channel Users
      • Direct Message Channels
      • Direct Message Channel Chat Messages
      • Direct Message Channel Users
      • Groups
      • Periods
      • Types
      • Users
      • Video Management System
  • Misc
    • Supported Language Codes
Powered by GitBook
LogoLogo

ALO.ai

  • ALO.ai

© Copyright 2025 ALO.ai, Inc. • All Rights Reserved

On this page
  • Send a message
  • Receive new messages
  1. SDKs
  2. Chat

Send Messages

Send and receive messages with custom metadata and file attachments using ALO's JavaScript SDK.

Send a message

You can send a message as a reply, with custom metadata, and even pass a list of File objects all in one command.

chat.sendMessage({
    channelId: "alpha",
    content: "<p>Hello, World!</p>",
    metadata: {
        coordinates: "27.9881,86.9250",
        temperature: "69.3"
    },
    parentId: "8e8a4e05-12e3-43b5-882e-d9711426f8e3",
    files: []
}).then((res) => {
    if (res.status.error) {
        console.log(`Send Message Failed:
            Reason: ${res.status.errorData.message}
            (Status Code: ${res.status.errorData.statusCode})
        `);
        return;
    }
    const message = res.response.message;
});    

sendMessage({ channelId: string, content: string, ... })

Name

Type

Required

Description

channelId

string

yes

The id of the channel that the message will be added to. ThechannelId must be included in the list of channelIds that were passed when generating the authToken.

content

string

yes

The content of the message.

metadata

plain object

no

The metadata of the message is a custom object allowing you to attach any information you need directly onto the message.

parentId

string

no

If the message is a reply to another message, set the parentId to the id of the parent message.

files

no

An array of File objects that will be automatically uploaded to ALO's media servers and metadata persisted on the message

Receive new messages

chat.addEventListener(function(event) {
    if (event.type === "message.new") {
        const { message } = event.data;
        console.log("New message: ", message);
    }
})

chat.subscribe({
    channelIds: ["alpha", "bravo"]
})

subscribe({ channelIds: [string] })

Name

Type

Required

Description

channelIds

array [string]

yes

An array of channelIds that specify which channels you want the client to receive events for through the function passed to addEventListener.

PreviousConfigurationNextUpload Files

Last updated 8 months ago

array []

File