From 063de44fcf511829ecef6e138643610ea0d0563a Mon Sep 17 00:00:00 2001 From: Anand Suthar Date: Fri, 7 Jun 2024 15:30:10 +0530 Subject: [PATCH] Method to send notification to users --- lib/novu/index.tsx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 lib/novu/index.tsx diff --git a/lib/novu/index.tsx b/lib/novu/index.tsx new file mode 100644 index 00000000..e755e054 --- /dev/null +++ b/lib/novu/index.tsx @@ -0,0 +1,22 @@ +import { Novu } from "@novu/node"; + +export default async function sendNotification(subscriberId: string) { + try { + const novu = new Novu(process.env.NOVU_API_KEY || ""); + + await novu.subscribers.identify(subscriberId, {}); + + novu.trigger("pft", { + to: { + subscriberId, + }, + actor: "https://media.tenor.com/iwXHwlY31ecAAAAM/yuji-itadori-suku.gif", + payload: {}, + }); + + return subscriberId; + } catch (error) { + console.error("Error sending notification :", error); + throw error; + } +}