Skip to content

GetEventPrediction

Source: src/AWS/FraudDetector/GetEventPrediction.ts

Submit an event to a bound Amazon Fraud Detector detector and receive the real-time model scores and rule outcomes for it — the effectful prediction call made from a deployed Lambda or Task.

Provide the GetEventPredictionHttp implementation layer on the Function effect, bind the detector in the init phase, then call the returned client at runtime. The binding grants frauddetector:GetEventPrediction on the detector and injects its detectorId automatically.

// init
const getEventPrediction = yield* FraudDetector.GetEventPrediction(detector);
return {
fetch: Effect.gen(function* () {
// runtime
const { ruleResults } = yield* getEventPrediction({
eventId: "order-123",
eventTypeName: "purchase",
eventTimestamp: new Date().toISOString(),
entities: [{ entityType: "customer", entityId: "cust-1" }],
eventVariables: { email: "fraud@example.com", ip: "1.2.3.4" },
});
const outcomes = ruleResults?.flatMap((r) => r.outcomes ?? []);
return HttpServerResponse.json({ outcomes });
}),
};
// on the Function effect:
// .pipe(Effect.provide(FraudDetector.GetEventPredictionHttp))