Recent Login
API Reference
Subscribers
- GETGet subscribers
- POSTCreate subscriber
- POSTBulk create subscribers
- GETGet subscriber
- PUTUpdate subscriber
- DELDelete subscriber
- PUTUpdate subscriber credentials
- DELDelete subscriber credentials by providerId
- PATCHUpdate subscriber online status
- GETGet subscriber preferences
- GETGet subscriber global preferences
- PATCHUpdate subscriber preference
- PATCHUpdate subscriber global preferences
- GETGet in-app notification feed for a particular subscriber
- GETGet the unseen in-app notifications count for subscribers feed
- POSTMark a subscriber feed message as seen
- POSTMarks all the subscriber messages as read, unread, seen or unseen. Optionally you can pass feed id (or array) to mark messages of a particular feed.
- POSTMark message action as seen
- GETHandle providers oauth redirect
- GETHandle chat oauth
Topics
Notification
Workflows
Workflow Overrides
Workflow groups
Integrations
Layouts
Execution Details
Organizations
Recent Login
Notify users of recent login activity
Intro
Sending recent logins is a great way to inform users of possible unusal activity and verify their usage. This workflow example leverages the payload schema to display the login IP, and notifies users through both email and a push notification.
Explore the source code on GitHub
Preview
Code Example
import { workflow } from '@novu/framework';
import { renderLoginEmail } from '../emails/yelp-recent-login';
import { zodControlSchema, zodPayloadSchema, zodPushControlSchema } from './schemas';
export const YelpRecentLogin = workflow(
"Yelp Recent Login",
async ({ step, payload }) => {
/**
* Email Flow
*/
await step.email(
"send-email",
async (controls) => {
return {
subject: "Recent login to your Account",
body: renderLoginEmail(controls, payload),
};
},
{
controlSchema: zodControlSchema
},
);
/**
* Push Flow
*/
await step.push(
"send-push",
async (controls) => {
return {
subject: controls.pushNotificationSubject,
body: `Hi ${payload.userFirstName}, we noticed a recent login to your Yelp account. If this was you, there's nothing else you need to do. If this wasn't you or please see our support page.`,
};
},
{
controlSchema: zodPushControlSchema
}
);
},
{
payloadSchema: zodPayloadSchema
},
);
Was this page helpful?
On this page