Creating messages visible only to agents in Rocket Chat App

In my app I’m trying to create a message visible only to chat agent using the method executePostLivechatAgentAssigned.
With the follow code both parts receive the message.

const modifyCreator = await modify.getCreator();
const blockBuilder = modifyCreator.getBlockBuilder();
blockBuilder.addActionsBlock({
    blockId: 'subreddits',
    elements: [
        blockBuilder.newButtonElement({
            text: blockBuilder.newPlainTextObject('Vitrine'),
            style: ButtonStyle.PRIMARY,
            url: 'https://trinks.com/'
        })
    ],
});

const infoMsgBuilder = modifyCreator
                .startMessage()
                .setRoom(context.room)
                .setBlocks(blockBuilder);
modify.getNotifier().notifyUser(user, infoMsgBuilder.getMessage());
await modify.getCreator().finish(infoMsgBuilder);

Did you ever get this? If not, then remove the very last line as that is sending it to both. The notifier only sends a message to one individual while the modify’s creator sends it to the room

Hi Bradley, thanks.
I manage to solve the problem exactly removing this line.

1 Like