Skip to content

RoomMessageReviewEventSource

Source: src/AWS/IVSChat/RoomMessageReviewEventSource.ts

Event source connecting an IVS Chat Room’s message review handler to the hosting Lambda function — every message sent to the room is synchronously reviewed (allow / modify / deny) by the handler before delivery.

At deploy time the Lambda implementation (Lambda.RoomMessageReviewEventSource) injects the function ARN into the room’s messageReviewHandler (via the room’s binding contract) and creates the lambda:InvokeFunction Permission for ivschat.amazonaws.com; at runtime it dispatches review invocations for the bound room to the handler and returns the verdict to IVS Chat.

Use the onReviewMessage helper rather than the service directly, and provide Lambda.RoomMessageReviewEventSource on the hosting function.

export default ChatFunction.make(
{ main: import.meta.url },
Effect.gen(function* () {
const room = yield* IVSChat.Room("LiveChat");
// deploy: sets the room's messageReviewHandler + invoke Permission
// runtime: reviews every message sent to the room
yield* IVSChat.onReviewMessage(room, (event) =>
Effect.succeed(
event.Content.includes("banned-word")
? { ReviewResult: "DENY", Attributes: { Reason: "moderated" } }
: { ReviewResult: "ALLOW", Content: event.Content.trim() },
),
);
return {};
}).pipe(Effect.provide(Lambda.RoomMessageReviewEventSource)),
);