Text Message

Initiate the messaging with the following scripts, depending on your platform of choice

import { MessageRepository } from '@amityco/js-sdk';

const liveObject = MessageRepository.createTextMessage({
  channelId: 'channel1',
  text: 'Hello World!',
});

liveObject.on('dataUpdate', message => {
  console.log('message is created', message);
});

When creating a message, we can also pass the parentId to make it appear under a parent.

import { MessageRepository } from '@amityco/js-sdk';

const messageLiveObject = MessageRepository.createTextMessage({
  channelId: 'channel1',
  text: 'Hello World!',
  parentId: 'exampleParentMessageId,
  tags: ['tag1', 'tag2'],
  mentionees: [
    {
      "type": "user",
      "userIds": [
        "user1", “user2”
      ]
    }
  ]
});

The limit for sending text messages is 20,000 characters per text message. Messages exceeding that limit will return an error and will not be sent.

Last updated