1. Chat
Worknation Rebuild
  • API GATEWAY(FOR FRONTEND)
    • Onboarding
      • Applicants
        • Nigerian Onboarding
        • Africa
        • Verify BVN
        • Verify Nin
        • Fetch all applicants
      • Employer
        • Roles
          • Ge role by id
          • Add
          • Fetch all
          • Delete
          • Update
        • Outside nigeria
        • Update Employee
        • Create Employer
        • Add employee
        • Fetch all employee
        • Fetch all employers
        • Verify Tin
      • Countries
        • Fetch all countries
      • Sponsor
      • Sponsor
        • Create sponsor
      • Admins
        • Create Admin
        • Fetch All
    • Auth
      • All countries
      • Generate Presign Url
      • Login page statistics
      • Verify Email
      • Resend Token
      • Company login
      • employee login
      • Get user's profile image url
      • login as talent
      • login as employer
      • Me
      • Logout
      • Verify token
    • User
      • Applicants
        • Proficience
          • Select skills
          • Fetch all
        • Educational Level
          • Fetch All
        • Schools
          • Fetch All
        • Job Applications
          • Talents
            • Save Job as Draft
            • Get Job Application status
            • Application Status
            • Apply for a role
            • All jobs applied
            • All jobs not applied
            • Get application
          • employer
            • Fetch all Applicant for a job
            • Update hiring status
        • Training Applications
          • Talents
            • Apply for a training
            • All training applied
            • All training not applied
            • Get application
          • employer
            • Fetch all Applicant for a job
            • Update applicatio status
          • check status
        • Statistics
          • Get talent dashbaord stats
        • Upload Intro vide
        • Talent update profile
      • Employer
        • Industry Types
          • Fetch ALl
        • employer types
          • Fetch All
        • Company
          • Create
          • Fetch
          • Get One
          • Deleted
          • Update
        • Contact Persons
          • Add Contact person
          • Fetch all employer contact person
        • WebHooks
          • Add Web url
          • Get All events
          • Get all employers selected
        • Sponsorship
          • Employer Become a sponsor
        • Training Reports
          • Get All Training Reports By Employer
          • Get Single Training Report By Employer
        • Employer update profile
      • Job Preference
        • Fetch all
      • Career Levels
        • Fetch ALL
      • Testimonials
        • Delete A Testimonial By Id
        • Create a Testimonial [applicant]
        • Fetch One Testimonial By User Token
        • Update Testimonial By user token [Applicant]
        • Fetch All Testimonials (Admin)
        • Approve A Testimonial By User ID [Admin]
      • Disabilities
        • Get All
      • System Roles
        • Add SystemRole
        • Get All SystemRole
        • Get SystemRole By ID
      • Destroy user
      • Get user by id
      • Get user's profile completion percentage
      • Activate By Email
      • Get User By Email
      • Get user by uuid
      • Forgot password
      • Reset Password
      • Change Password
      • Upload avatar/logo
    • Permissions
      • Fetch ALl
    • HR
      • Jobs
        • Create job
        • Fetch all jobs
        • Fetch all landing page jobs
        • Get job recommedations
        • Fetch all employers jobs
        • Fetch job by id
        • Fetch job by slug
        • Update Job Status
        • Update job
        • Toggle draft status to applied
        • Get Job Prequalification questions
        • Fetch All Company Jobs
      • Trainings
        • Create trainings
        • Fetch all trainings
        • Fetch all employers trainings
        • Fetch trainings by id
        • Fetch trainings by slug
        • Update trainings Status
        • Update trainings
      • Statistics
        • Get Employers dashbaord stats
      • shortlisted-candidates
        • Accept candidates application for job
        • Reject candidates application for job
        • Shortlist candidate for Job application
        • Get shortlisted candidates for all Jobs created by current employer
        • Shortlisted candidates remark(To pass or fail candidate).
      • sponsorship
        • documents
          • Upload sponsorship document
          • Upload application document
        • Applications
          • Apply for sponsorship
          • Get application by ID
          • Get applications by sponsorship
          • Get applications by applicant
          • Update application approval
        • Approvals
          • Take approval action
          • Get approval workflow
          • Get approval history
        • Create a new sponsorship
        • Get all sponsorships
        • Update sponsorship
        • Delete sponsorship
        • Get sponsorship by ID
      • Get Faq
    • Skiils
      • Add
      • Fetch all
      • fetch one
      • Update
      • Delete
    • Admin
      • Pre-Qualification Questions
        • Create questions
        • Fetch all
        • Update
        • Delete
        • Fetch one
      • Fetch All Talents
      • Get All Employers
      • Admin Dashboard Statistics
      • Invite Users (file upload)
      • Invite applicants
    • Assessment
      • Onboarding
        • Applicant Assessment Portal Onboarding
        • Employer Assessment Portal Link
        • Onboarding
      • Create assessment
        • Results
          • Get all Results
          • Get Talent scores
          • Get result by id
        • Get All Assessment (Bank)
        • Create
        • Fetch assessment by title
        • Get Assessment by id
        • Submit answers
        • Add Questions To Assessment
        • Delete Question From Assessment
        • Update Question in Assessment
        • Set Questions To Inactive
      • Skills
        • Create Skills
        • Fetch all skills
        • Fetch skill by id
        • Update Skill
        • Remove skill
      • Coding Challenges
        • Create
        • Fetch All
        • Fetch One
        • Submit Challenge
        • Update
        • Remove
        • Add programming language
        • Fetch all programming languages
        • Fetch programming language by id
        • Fetch programming language by name
        • RUN Code
        • Invite applicants by email
        • Get coding challenge details by encrypted value
        • Get coding challenge results for challenge
        • Get coding challenge results for user by id.
        • Get user's result for a challenge.
        • Coding challenges test cases results
      • Api Keys
        • Create
        • Fetch keys by company id
        • Fetch by key id
        • Delete
        • Find all keys
      • Roles
        • Fetch all role
        • Create
        • Fetch role by id
        • Seed Roles
      • personality-test
        • Retrieve All Categories
        • Submit Personality Assessment Answers
        • Retrieve User Assessment Results
        • Retrieve User Assessment Score
        • Retrieve Assessment Result by ID
        • List All Questions with Pagination
        • Retrieve Question by ID
        • Create a New Question
        • Update a Question
        • Delete a Question
        • Check if User has taken Assessment test
        • Seed categories
        • Get Reports
        • Get detailed info for category by ID.
        • Retrieve User Assessment Results by user Id
      • soft-skills
        • Get All Categories
        • Submit Soft Skill Assessment Answers
        • Get User's Assessment Results
        • Get Assessment Result by ID
        • Get User's Assessment Score
        • Get All Questions with Pagination
        • Get Question by ID
        • Delete a Question
        • Create a Question
        • Update a Question
        • Get Headings
        • Check if User has taken Assessment test
        • Seed Categories
        • Get Reports
        • Get User's Assessment Results by user id
      • culture-fit-assessment
        • Retrieve All Categories
        • Submit Culture Fit Assessment Answers
        • Retrieve User Assessment Results
        • Retrieve User Assessment Score
        • Retrieve Assessment Result By ID
        • List All Questions With Pagination
        • Retrieve Question by ID
        • Create New Question
        • Update a Question
        • Delete a Question
        • Check if User has taken assessment test
        • Seed Categories
        • Get Reports
        • Retrieve User Assessment Results by User Id
      • Seeders
        • Seed Soft skills category
        • Seed Culture fit category
        • Seed personality Test category
        • SeedRoles
        • Seed Question Types
        • Fetch All Question Types
      • Comprehension Assessments
        • Post Assessment
        • Get ALL
      • Scenario Assessment
        • Post A Question
        • Retrieve All Question
        • Retrieve One Question
        • Update Question
        • Delete Question By ID
        • Submit Scenario Test
        • View All User Results
        • Check If User Has Taken Test
        • View Result By ID
        • View Result By User ID
      • Integrity Assessment
        • Post A Question
        • Get All Questions
        • Get Question By ID
        • Update Question By ID
        • Delete Question By ID
        • Submit Test
        • View User Results
        • Get Assessment Reports
        • Check If User has taken test
      • Level One Questionaire
        • Submit Answers
        • Get All Responses
        • Get User Response
        • Check If User Has Submitted
        • Create Question
        • Get All Questions
        • Get Question By Id
        • Update Question
        • Delete Question By Id
        • Update Questions Status
      • comprehension assessment
        • Get random sentence from prepoluated sentence in the db.
        • Submit comprehension assessment
        • Get user's assessments
        • Get assessment results by ID
    • Recruitment
      • cv-builder
        • Create/Edit a cv
        • Delete Created CV
        • Fetch all CVs attached to an applicant
        • Delete a job project pipeline
        • Get generated CVs for Applicant
        • Generate PDF for CV.
        • Delete Generated CV
        • Get User cv data
        • Get generated cv url by ID
        • Upload CV file
        • Fetch all CVs attached to a user ID
        • Get generated CVs for user by user ID
      • JobProjectPipelines
        • Create a new job project pipeline
        • Retrieves all job project pipelines for the authenticated employer.
        • Get a specific job project pipeline
        • Update a job project pipeline
        • Get all employer-created projects
        • Get applicants in a specific pipeline
        • Search candidates
        • Add applicants to a pipeline
        • Remove applicants from a pipeline
    • parkway-wallet
      • Create Parkway-wallet
    • LMS
      • Fetch All Courses
      • Fetch All Categories
      • Create enployer
      • Create Talent
      • Fetch One course
      • Enroll applicant for a course
      • Check if user is enrolled for course
      • Get user enrolled courses
    • Worknation LMS
      • Super-Admin
        • Company
        • Reporting
          • Stats
          • Trainings
          • Export Trainings
          • NYSC
          • Export NYSC Talents
        • Fetch All Companies
        • Create Company
      • Talents
        • Get All Talents
        • Check User Exist
        • Make Course Creator
        • Bulk Update NYSC Talents
        • Learning Academies
        • Reset Password
        • Update Username
        • Update Profile
        • Get Log
        • Clear Log
        • Fix Context
        • get env
        • Add/Edit Values
        • Clear Cache
        • Run Query
        • Create new talent
      • Courses
        • Get All Courses
        • View Course
        • Get All Courses Fixed
        • Get Completion Progress
      • Enrollments
        • View Enrollment Applications Copy
        • Moodle Enrol User To Course
        • Talent Enrolled Courses By Email
        • Get Enrolment Status
        • Get All Talent Enrolments
        • Enrol Talent To Course Copy
        • Approve Enrollment Request
        • Decline Enrollment Requests
        • All Enrollment Applications
    • Attendance system
      • Generate QR code - Admin
      • Check-in and check-out student.
      • Get all attendance records with various optional filtering options
      • Get attendance logs for current user
    • Admin KPI
      • Cohorts
        • Create Cohort
        • Get All Cohorts
        • Get A Cohort By Id
        • Update Cohort By Id
        • Delete Cohort By Id
        • Add Talent to Cohort
        • Add Instructor to Cohort
      • Instructors
        • Add Instructor
        • Get All Instructors
        • Instructor Sign In
        • Get Instructor By Id
        • Update Instructor By Id
        • Delete Instructor By Id
        • Instructor Forgot Password
        • Instructor Reset Password
      • Reviews
        • Rate Instructor
      • Skills
        • View All Skills
    • Partners
      • Login
      • Create
      • Create Keys
      • Fetch Keys
      • Add Talents To Worknation
    • AI/ML
      • Assessment
        • Live Image verification
      • Get Talent By id
    • SUbscription Plan
      • Get All
    • MSD
      • Register new user in background (works for only email)
      • Decrypt token.
      • Get user's responses for profile questions(MSD)
    • Notifications
      • Fetch All
      • mark-all-read
      • mark-read
      • Get Stats
    • Chat
      • Chat Web Sockets
      • User Onboarding
        POST
      • Get All Chats By User ID
        GET
      • Initialize User
        POST
      • Get Initialized Users
        GET
      • Create Chat
        POST
      • Get Chat Members
        GET
      • Get Chat By Id
        GET
      • Find Or Create user
        POST
    • Internship
      • Category
        • Seed Program Categories
        • Fetch category
      • Intership Program
        • create Internship
        • get all Internship
        • delete Internship by id
        • update Internship by id
        • get one internship by id
        • Get Internship By Slug
        • Get All Employer Internship
      • Internship Application
        • Apply for internship (Talent)
        • Approve Internship Application
        • Reject Internship Application
      • Mentors
        • Create Mentor
        • Get All Employer Mentors
        • Get All Mentors
        • Delete A Mentor
        • Assign mentor to Internship
        • Mentor Dashboard Stats
      • KPI
        • Create KPI
        • Get All KPIs
        • Get One KPI By Id
        • Update One KPI
        • Delete One KPI
        • Intern KPI Submission
        • Get All Submissions
        • Mentor to Score Project Submission
        • Mentor To View All Assigned Internships
        • Fetch All Internship KPIS
        • Fetch All Submissions By Kpi ID
        • Candidates Submission By kpi ID
      • Application Status
        • Fetch Application Status
        • Fetch Employer Internship Application By Slug & Status
      • Candidates
        • View All Enrolled Programs
        • Get All candidate submissions
      • Get All Employer Talents
      • Fetch Talent Applications by Status
      • Get All Internship Applications By ID
      • Get Employer Talents with Token
      • Employer Report
    • support
      • Create support account(super admin)
      • Get worknation users
      • Get all support users
    • NYSC
      • Request for otp using NYSC callup number
      • Verify otp
  • External
    • User
      • Get Applicant by Reference
    • Files(Videos, images or CVs)
      • Get files by reference
    • Role Relay
      • Talents
        • Get Profile image by WnId
        • Get Talent by WnId
        • Get CV By WnId
        • Get Intro Video by WnId
      • Webhooks
        • Send Data to Worknation
  • Testing
    POST
  1. Chat

Chat Web Sockets

WebSocket API Documentation#

This document outlines the WebSocket API for the Worknation Chat application, managed by AppGateway.

1. Connection Setup#

Clients should connect to the WebSocket server endpoint.

Authentication#

Authentication is handled via a userId and token passed in the handshake.query during the initial WebSocket connection.
client.handshake.query.userId: (Required) The numeric ID of the connecting user.
The server uses WncUserGuard to protect most WebSocket events. If authentication fails during connection or for an event, the client might be disconnected or receive a WsException.

Online Status#

The server maintains a list of currently connected (online) users. This is used, for example, to deliver messages directly to a receiver's socket if they are online.

2. Data Transfer Objects (DTOs)#

CreateMessageDto#

Used as the payload for the create_message event.
FieldTypeValidationDescription
chat_idnumberNotEmptyThe ID of the chat session.
receiver_idnumberNotEmptyThe ID of the message recipient.
messagestringNotEmptyThe content of the message.

3. WebSocket Events#

Events are categorized by their direction: Client-to-Server (messages the client sends) and Server-to-Client (messages the server sends).

3.1. Connection Lifecycle Events (Handled by Server)#

connection (Implicit Client-to-Server)
Description: Triggered when a new client establishes a WebSocket connection. The server attempts to authenticate the user using userId from client.handshake.query. If successful, the user is added to an internal list of online users.
Payload (Client Handshake Query): { userId: number }
disconnect (Implicit Client-to-Server)
Description: Triggered when a client's WebSocket connection is closed. The server removes the user from the internal list of online users.

3.2. Client-to-Server Events (Subscribed Messages)#

create_chat#

Description: Initiates the creation of a new chat session between the sender (connected user) and a specified receiver.
Payload: { receiver_id: number }
receiver_id (number): The ID of the user to start a chat with.
Server Response: Emits chat_created to the sender on success.
Error: Throws WsException on failure.

create_message#

Description: Sends a new message within a chat.
Payload: CreateMessageDto (see section 2 for structure)
Server Response:
Emits response_message to the sender with the created message.
Emits response_message to the receiver (if they are online) with the created message.
Error: Throws WsException on failure.
Note: If the receiver is offline, a "TODO" in the code suggests sending an "inMail" (this behavior might not be fully implemented via WebSockets).

seen_message#

Description: Marks messages within a specific chat as "seen" by the connected user.
Payload: { chat_id: number }
chat_id (number): The ID of the chat where messages should be marked as seen.
Server Response: None explicitly on success.
Error: Throws WsException on failure.

chat_messages#

Description: Requests all messages for a specific chat.
Payload: { chat_id: number }
chat_id (number): The ID of the chat to retrieve messages for.
Server Response: Emits get_all_chat_messages to the sender with an array of message objects.
Error: Throws WsException on failure.

get_chats#

Description: Requests all chat sessions for the connected user.
Payload: None (uses the authenticated user's ID).
Server Response: Emits updated_chat_list to the sender with an array of chat objects.
Error: Throws WsException on failure.

3.3. Server-to-Client Events (Emitted Messages)#

chat_created#

Description: Confirms that a new chat session has been successfully created.
Payload: The newly created chat object.
Recipient: The client that initiated the create_chat request.

response_message#

Description: Delivers a new message.
Payload: The created message object.
Recipients:
The client that sent the create_message request.
The intended receiver of the message, if they are currently online.

get_all_chat_messages#

Description: Provides the list of messages for a requested chat.
Payload: An array of message objects.
Recipient: The client that initiated the chat_messages request.

updated_chat_list#

Description: Provides the updated list of chat sessions for the user.
Payload: An array of chat objects.
Recipient: The client that initiated the get_chats request.

4. Error Handling#

Failures in processing WebSocket events will typically result in a WsException being thrown by the server. The client should be prepared to handle these exceptions. The error object usually contains a message property with details about the error.
Modified at 2025-06-18 10:42:58
Previous
Get Stats
Next
User Onboarding
Built with