Skip to content

API Triggered Notifications #474

Closed
Closed
@maxceem

Description

@maxceem

Context

Project Context

TaaS (Talent as a Service) is Topcoder project which let customers to hire top freelancers for gigs and directly manage the talents.

Challenge Context

The TaaS workflow looks like this:

For now users don't know if some action in this workflow is required from them. So we would like send them notifications to remind them to take a pending action.

Expected Outcome

Implement 5 kind of notifications send by API endpoints.

Challenge Details

Technology Stack

  • Node.js
  • PostgreSQL

Code access

The work in this challenge would be done in 1 repository:

Individual requirements

Notifications

  • New Team Created

    • Description: send notification when a new Team was created using endpoint "POST /taas-teams/submitTeamRequest".
    • Recipients by Email: all members of the Team.
    • Content: Team Name, Job List: with Job title, duration and start date
    • Type: "taas.notification.team-created"
  • New Job Created:

    • Description: send notification a new Job was created.
    • Recipients by Email: all members of the Team.
    • Content: Team Name, Job title, duration and start date
    • Type: "taas.notification.job-created"
    • NOTE: during Team creating some jobs are also created together with Team. We have to make sure that we only send notifications when Jobs are created for existent Team, not when Jobs are created together with the Team.
  • Overlapping Interview Invites

    • Description: send notification if there is a new Interview created which overlaps existent interview by time (from "startTimestamp" till "endTimestamp"). Do the same if we update start/end timestamp for Some Interview and now it overlaps with another one.
    • Recipients by Slack: Slack chat defined by env variable
    • Recipients by Email: Comma separated list in env variable "NOTIFICATION_OPS_EMAILS"
    • Content: Data related to both conflicting Interviews: Team Names, Team URLs, Job Titles, Job URLs, Job Candidate user handles, Interviews start/end times
    • Type: "taas.notification.interviews-overlapping"
  • Job Candidate is Selected

    • Description: send notification if Job Candidate status has been change to "selected" or Job Candidate has been created with "selected" status.
    • Recipients by Slack: Slack chat defined by env variable
    • Recipients by Email: Comma separated list in env variable "NOTIFICATION_OPS_EMAILS"
    • Content: Team Name, Jobs Title, Job URLs, Job startDate and duration, Candidate user handle
    • Type: "taas.notification.job-candidate-selected"
  • Resource Booking is Placed

    • Description: send notification if Resource Bookings was created with status "placed" or existent record updated to status "placed".
    • Recipients by Email: all members of the Team.
    • Recipients by In-App: all members of the Team.
    • Content for Email: Team Name, Job Title, Resource Booking user handle, start/end dates
    • Data for In-App: teamName, projectId, userHandle, jobTitle
    • Type: "taas.notification.resource-booking-placed"

Triggering Notifications

To trigger these notification we would have to react to some API actions. We have internal event system inside the TaaS API to catch such events inside "src/eventHandlers" folder. Create new functions inside these files and call them on the events we need to catch to trigger sending these notifications.

Send notifications

To send notifications using "Email", "Slack" or "In-app" we have to use the same way: send Kafka message to the topic "notifications.action.create" with the next payload https://gist.github.com/maxceem/bb2ad68d2f8a790f01e3326f9f8015eb. Note, that we can send one Kafka message to send notifications using several services at once, for example we can send notification by Email and Slack at once.

Email template

Update Email template to support new notification types in "data/notifications-email-template.html".

  • Email Template should be compatible with email clients, i. e. inline CSS, use tables for layout and so on. But actually you should change only the inner part and you can use very simple code for this similar to provided example.

Slack

Format the content of Slack message nicely using "blocks" (https://gist.github.com/maxceem/bb2ad68d2f8a790f01e3326f9f8015eb#file-notification-action-create-js-L67) see https://api.slack.com/block-kit.

In-App

For in-app notifications pass the same data as for email notifications data mentioned in "Data for In-App" inside content field. Rendering notifications is not in scope.

Verification Guide

  • Create requests inside Postman folder "Notifications Demo" to trigger all of these notifications. We already have some of them. All such requests should be named "[Notification Name]".
  • To validate email notifications, run use https://github.com/topcoder-platform/taas-apis/tree/dev/scripts/demo-email-notifications. So when we would trigger API using Postman we should see how this script renders emails inside the "out" folder.
  • To validate Slack notifications, setup-up a demo channel https://api.slack.com/messaging/webhooks and provide screenshots of rendered messages.
  • Validating in-app notifications is not required, just send the same data for them as for emails.

General requirements

  • Follow the existent code structure.
  • Split code into reusable methods where applicable.
  • Existent unit tests should pass.
  • Lint should pass.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions