Backend application for Life Chat - platform helping psychologists to work with their patients throw chat messengers.
- Node
- Koa
- Joi
- MongoDB
- Telegram Bot API
- Set environment variables or use
.env
file. Example:DB_URI=mongodb://127.0.0.1:27017/lifechatdb JWT_SECRET=84573695730af7da3ab1bb716f745df7 NODE_ENV=production PORT=8000 API_VERSION=1
- Install npm dependencies:
npm install
- Run the app:
npm start
Creates a new user
{
"first_name": string,
"last_name": string,
"patronymic": string,
"inn": string,
"phone": string,
"email": string,
"nationality": string
}
{
"id": string,
"created_at": string,
"first_name": string,
"last_name": string,
"patronymic": string,
"inn": string,
"phone": string,
"email": string,
"nationality": string,
"experience": string,
"rate": string,
"welcome_message": string
}
Authenticates a user based on credentials
{
"username": string
"password": string
}
{
"auth_token": string // JWT token
}
Updates user's Telegram bot configuration parameters
{
"token": string // User's Telegram bot token
}
{
"result": "SUCCESS"
}
Updates user details
{
"rate": number, // Hourly pay rate in local currency
"experience": number, // Years of experience
"welcome_message": string // First consultation message content to be sent to patients
}
{
"result": "SUCCESS"
}
Updates user payment parameters
{
"card_number": string // User's bank card number, to which payments will be sent from patients
}
{
"result": "SUCCESS"
}
Fetches authenticated user parameters
{
"id": string,
"created_at": string,
"first_name": string,
"last_name": string,
"patronymic": string,
"inn": string,
"phone": string,
"email": string,
"nationality": string,
"experience": string,
"rate": string,
"welcome_message": string
}
Fetches authenticated user's consultations
{
"id": string,
"created_at": string,
"status": string,
"duration": number,
"total_cost": number,
"can_send_message": boolean,
"scheduled_on": string
}[]
Fetches consultation by ID
{
"id": string,
"created_at": string,
"status": string,
"duration": number,
"total_cost": number,
"can_send_message": boolean,
"scheduled_on": string
}
Fetch messages by consultation ID
{
"id": string,
"text": string,
"sent_at": string,
"patient": Patient
}[]
Sends message to the open consultation Telegram chat
{
"text": string
}
{
"id": string,
"text": string,
"sent_at": string,
"patient": Patient
}
Launches the consultation flow. Changes status of consultation from NEW
to PENDING
.
{
"result": "SUCCESS",
"status": "PENDING"
}
Marks consultation as prepaid. Changes status of consultation from PENDING
to PREPAID
.
{
"result": "SUCCESS",
"status": "PREPAID"
}
Completes the consultation. Changes consultation status to WAIT_PAYMENT
.
{
"result": "SUCCESS",
"status": "WAIT_PAYMENT"
}