How can i add two line breaks(\n\n) at the start of every message response recieved from openai under the resume category?
Code:
const fs = require("fs");
const { Configuration, OpenAIApi } = require("openai");
let Chatgpt = {};
const mongoose = require("mongoose");
const config = require("../config.json");
const prompt = require("../../../prompt.json");
const ObjectId = require('mongodb').ObjectId;
// let conUser = mongoose.createConnection(config.mongo.dbUrl);
// console.log( process.env.DB_URL)
// let conUser = mongoose.createConnection(
//   "mongodb://3.132.60.39:27017/admin",
//   {
//     "auth": {
//       "authSource": "admin"
//     },
//     "user": "adminUser",
//     "pass": "adminUserTamara",
//   }
// );
let conUser = mongoose.createConnection(
  process.env.DB_URL,
  {
    "auth": {
      "authSource": "admin"
    },
    "user": process.env.DB_USERNAME,
    "pass": process.env.DB_PASSWORD,
  }
);

const CategorySchema = require("../../../Schema/Category");
const UserSchema = require("../../../Schema/User");
const HistorySchema = require("../../../Schema/History");
const SavedmessagesSchema = require("../../../Schema/Savedmessages");
const CategoryModel = conUser.model("CATEGORY", CategorySchema, "Category");
const UserModel = conUser.model("USER", UserSchema, "User");
const HistoryModel = conUser.model("HISTORY", HistorySchema, "History");
const SavedmessageModel = conUser.model("SAVEDMESSAGE", SavedmessagesSchema, "Savedmessage");

const configuration = new Configuration({
  apiKey: process.env.OPENAI_API_KEY,
});

const openai = new OpenAIApi(configuration);

function sleep(ms) {
  return new Promise((resolve) => {
    setTimeout(resolve, ms);
  });
}

Chatgpt.botreplyfirst = async(req, res) => {
  
  let data=req.body;
  let message = data.message;
  let category_key = data.category_key;
  let tone = data.tone;
  let replyIn = data.replyIn;
  let formality = data.formality;
  let promptfilter = data.promptfilter;
  let promtmessage = "";
  let promtvalue = 0;
  // let packType = 0;
  let userToken = 0;
  let purchaseTime =0;
  if(promptfilter == "1"){
    promptfilter ="Please fix grammer and punctuations {explain the mistakes at the end}"
  }
  if(promptfilter == "2"){
    promptfilter ="Provide improvement in phrases that enhance clarity"
  }
  if(promptfilter == "3"){
    promptfilter ="Improve my writing style and provide stylistic suggestions and examples"
  }
  if(promptfilter == "4"){
    promptfilter ="Assist me with choosing the right word"
  }
  if(promptfilter == "5"){
    promptfilter ="Offer sentence structure suggestions along {with examples}"
  }
  return new Promise(async (resolve, reject) => {
    try {
  if(!message){
    reject("Message is required");
    return;
  }
  if(!tone){
    tone = "Confident"
  }
  if(!replyIn){
    replyIn = "American English"
  }
  if(!formality){
    formality ="Formal"
  }
  if(!promptfilter){
    promptfilter =" "
  }else{
  //  promptfilter = promptfilter+' and '
   promptfilter = '['+promptfilter+']'
  }

  if(!category_key){
    reject("category_key required");
      return;
  }
  let userId = req.authUser ? req.authUser.userId : 0;
    if (!userId) {
      reject("login required");
      return;
    }
    // let usrdata = await UserModel.findOne({ _id: userId }).select({
    //   email:1,
    //   name:1,
    //   _id:1,
    //   dob:1,
    //   gender:1,
    //   mobileNo:1,
    //   profilePicture:1,
    //   userToken:1,
    //   status:1,
    //   feedback:1,
    //   signuptype:1,
    //   access_token:1,
    // }).exec();
    // if(usrdata.status != "active"){
    //   reject("User is Inactive");
    // }

  let userdata = await UserModel.findOne({ _id: userId }).lean().exec();    
  let categorydata = await CategoryModel.findOne({ categorykey: category_key }).lean().exec();    
  
  if(category_key == 'social_media'){
    // promtmessage =promptfilter+' '+ prompt.Social_Media + ' for '+userdata.name  +'. '+' the reply should be in '+formality+ ' and '+tone+' tone. language should be '+replyIn+' for:' +'['+''+message+''+'].'
    promtmessage = '{YOU ARE A SOCIAL MEDIA CONTENT WRITER}'+promptfilter+'Generate message on behalf of- '+userdata.name+'.'+' {you must reply in '+formality+' and '+tone+' tone, in language '+replyIn+'}'+' content-'+'"'+message+'".'
  }
  if(category_key == 'email'){

    // promtmessage = `Perform the following actions on text delimited by triple dashes aand follow the instructions provided below: 1- output a email format message contains minimum 2 paragraphs subject should be relevant to the provided message in triple dashes 2- output should be as professional email writer format 3- output formailty should be in ${formality} 4- output tone should be ${tone} 5- the output language should be ${replyIn}. 6- output will be for ${userdata.name} ---${message}--- `
    promtmessage = `{YOU ARE ${userdata.name} WHOSE JOB IS TO DRAFT PROFESSIONAL EMAILS}. Perform the following actions on text delimited by triple dashes aand follow the instructions provided below: 1- Output a email format message contains minimum two paragraphs, subject should be relevant to the provided message in triple dashes. 2- Output should be as professional email writer format. 3- Output formailty should be in ${formality}. 4- Output tone should be ${tone}. 5- The output language should be ${replyIn}. ---${message}--- `
    // promtmessage = promptfilter+' '+ prompt.Email + ' for '+userdata.name  +'. '+' the reply should be in '+formality+ ' and '+tone+' tone language should be '+replyIn+' for:' +'['+''+message+''+'].'
  }  
  if(category_key == 'messages'){
    // promtmessage = promptfilter+' '+ ' for '+userdata.name  +'. '+' the message should be in '+formality+ ' and '+tone+' tone language should be '+replyIn+' for:' +'['+''+message+''+'].'
    promtmessage = `Plese respond to "${message}" on behalf of ${userdata.name} in ${formality} and ${tone} tone, in language ${replyIn}]${promptfilter}.`
  }  
  if(category_key == 'general'){
    // promtmessage = promptfilter+' '+ ' for '+userdata.name  +'. '+' reply in '+formality+ ' and '+tone+' tone and  the reply language should be '+replyIn+' for:' +'['+''+message+''+'].'
    promtmessage = promptfilter+' '+ ' for '+userdata.name  +'. '+' reply in '+formality+ ' and '+tone+' tone and  the reply language should be '+replyIn+' for:' +'"'+message+'".'
  }
  if(category_key == 'meeting_minute'){
    // promtmessage = 'Draft meeting minutes for the recent given message of meeting, including agenda items, discussions, and action items. '+ promptfilter+' '+ ' for '+userdata.name  +'. '+' reply in '+formality+ ' and '+tone+' tone and  the reply language should be '+replyIn+' for:' +'['+''+message+''+'].'
    promtmessage = '{YOU MUST RESPOND IN PROFESSIONAL MINUTE MEETING FORMAT based on the given content. Please include agenda, discussions and action items}'+promptfilter+'. Meeting is draft by-'+userdata.name+'.'+' Reply in '+formality+' and '+tone+' tone and the response must be in '+replyIn+'. Content of the meeting:' +'"'+''+message+''+'".'
  }
  if(category_key == 'resume'){
    // promtmessage = 'Please provide a summary of my qualifications, experience, and skills in a resume format of given message  ' +promptfilter+' '+ ' for '+userdata.name  +'. '+' reply in '+formality+ ' and '+tone+' tone and  the reply language should be '+replyIn+' for:' +'['+''+message+''+'].'
    promtmessage = `[MUST START YOUR RESPONSE WITH TWO LINE BREAKS]{You are ${userdata.name}, YOU MUST RESPOND IN A PROFESSIONAL RESUME FORMAT with POINTS(strictly no paragraph)} +${promptfilter}. Reply in ${formality} and ${tone} tone and the response must be in ${replyIn}. Your description to be used to create your resume-"${message}"`
  }
  if(category_key == 'report'){
    // promtmessage = 'Provide a Detailed and Report for '+'['+''+message+''+']'+ ' in a proper reporting format and ' + promptfilter+', '+' reply in '+formality+ ' and '+tone+' tone and  the reply language should be '+replyIn+'.Note- the response format should not be anywhere near to email format it should be strickly a reporting format with all the key points described with the agendas and important points highlights' 
    promtmessage = '{You must response in a professional report format for the content:"'+message+'". Please note that the response format should not be anywhere near to email format it should be strickly a reporting format with all the key points described with the agendas and important points highlights, and should be more than 500 words long}'+promptfilter+', '+' reply in '+formality+' and '+tone+' tone and  the language of response must be in '+replyIn
  }
  // console.log("promtmessage",promtmessage)
  // promtmessage ="Provide suggestions for sentence structure and Reply as a email writer the reply should be in formal and witty language should be english of message how to write good message for girlfriend "
  
  if(userdata.promptToken != undefined){
    promtvalue = userdata.promptToken 
  }

      // console.log(promtmessage)
      const response = await openai.createChatCompletion({
        model: "gpt-3.5-turbo",
        messages: [{"role": "system", "content": "You are a helpful assistant your name is tamara."}, {role: "user", content: promtmessage}],
      });
      console.log("promtmessage:-",response)
    //   const response = await openai.createCompletion({
    //     model: "text-davinci-002",
    //     prompt: promtmessage,
    //     max_tokens: 2000,
    //   temperature:0,
    // })
      await UserModel.findOneAndUpdate(
        { _id: userId },
        {
          $set: {
            promptToken:response.data.usage.prompt_tokens+promtvalue,
            // userToken:userToken-1,
            updatedAt: new Date()
          }
        },
        { new: true },
      );
      let userhistoryObject={
        message:message,
        message_from:"user",
        categorykey:category_key,
        categoryname:categorydata.name,
        user_id:userId,
        isLike: false,
        isDisLike: false,
        isSave: false,
        translator: false,
        status:1,
        createdAt: new Date()
      }
      await HistoryModel.collection.insertOne(userhistoryObject)
      await new Promise(resolve => setTimeout(resolve, 2000)); 

      let chatgpthistoryObject={
        // message:response.data.choices[0].text,
        message:response.data.choices[0].message.content,
        message_from:"chatgpt",
        categorykey:category_key,
        categoryname:categorydata.name,
        user_id:userId,
        isLike: false,
        isDisLike: false,
        isSave: false,
        translator: false,
        status:1,
        createdAt: new Date()
      }
     // code to make delay so that message sequence won't
      // await sleep(1000);
      await HistoryModel.collection.insertOne(chatgpthistoryObject)

      // response data...
    let findCase={user_id:userId};
    let historydataresp = await HistoryModel.find(findCase).sort({_id:-1}).limit(2)
    let chatgpt = historydataresp[0]
    let user = historydataresp[1]
      const data = {
        userMessage: {
          _id:  user._doc._id,
          message: user._doc.message,
          message_from: "user",
          createdAt:user._doc.createdAt,
          isLike: user._doc.isLike,
          isDisLike:  user._doc.isDisLike,
          isSave: user._doc.isSave,
          translator: user._doc.translator,
          user: {
            _id: userId,
            name:userdata.name,
            avatar: userdata.profilePicture,
          },
        },
        chatGPTMessage: {
          _id: chatgpt._doc._id,
          message: chatgpt._doc.message,
          message_from: "chatgpt",
          createdAt: chatgpt._doc.createdAt,
          isLike: chatgpt._doc.isLike,
          isDisLike:  chatgpt._doc.isDisLike,
          isSave: chatgpt._doc.isSave,
          translator: chatgpt._doc.translator,
          user: {
            _id: categorydata._id,
            name: categorydata.name,
            avatar: null,
          },
        }
        
      }
      resolve(data)

    } catch(error) {
      // Consider adjusting the error handling logic for your use case
      if (error.response) {
        console.error(error.response.status, error.response.data);
        reject(error.response)
      } else {
        console.error(`Error with OpenAI API request: ${error.message}`);
        reject('An error occurred during your request.')
      }
    }
  });
};

Chatgpt.botreply = (req, res) => {
  return new Promise(async (resolve, reject) => {
    try {
      const response = await openai.createChatCompletion({
        model: "gpt-3.5-turbo",
        messages: [{"role": "system", "content": "You are a helpful assistant your name is tamara."}, {role: "user", content: req.body.message}],
      });

      // const response = await openai.createCompletion({
      //   model: "text-davinci-002",
      //   prompt: req.body.message,
      //   max_tokens: 100,
      //   temperature: 0,
      // });
      resolve(response.data.choices[0].text)
    } catch(error) {
      // Consider adjusting the error handling logic for your use case
      if (error.response) {
        console.error(error.response.status, error.response.data);
        reject(error.response)
      } else {
        console.error(`Error with OpenAI API request: ${error.message}`);
        reject('An error occurred during your request.')
      }
    }
  });
};

Chatgpt.categories = (req) => {
  return new Promise((resolve, reject) => {
    let findCase={visibility:true};

    CategoryModel.find(findCase, function (err, response) {
      if (err) {

        reject(err);
      } else {

        if (response.length > 0) {
          resolve(response)
        }else{
          reject("not found!!")
        }
      }
     });
  });
};

Chatgpt.likemessage = async (req) => {
  let data=req.body;
  let likestatus = data.likestatus;
  let dislikestatus = data.dislikestatus;
  let id = data.id;

  if(!id){
    reject("id id required");
      return;
  }
  if(likestatus){
    likestatus = true
  }else{
    likestatus = false
  }

  if(dislikestatus){
    dislikestatus = true
  }else{
    dislikestatus = false
  }

  let userId = req.authUser ? req.authUser.userId : 0;
    if (!userId) {
      reject("login required");
      return;
    }
    // let usrdata = await UserModel.findOne({ _id: userId }).select({
    //   email:1,
    //   name:1,
    //   _id:1,
    //   dob:1,
    //   gender:1,
    //   mobileNo:1,
    //   profilePicture:1,
    //   userToken:1,
    //   status:1,
    //   feedback:1,
    //   signuptype:1,
    // }).exec();
    // if(usrdata.status != "active"){
    //   reject("User is Inactive");
    // }
    
  return new Promise((resolve, reject) => {

     HistoryModel.findOneAndUpdate(
      { _id:new ObjectId(id)  },
      {
        $set: {
          isLike:likestatus,
          isDisLike:dislikestatus,
          updatedAt: new Date()
        }
      },
      { new: true },
      function (err, data) {
        if (err) {
          reject(err);
        } else {
          if (data) {
            resolve("Message Like status updated");
          } else {
            reject("Message not found");
          }
        }
      }
    );
  });
};

Chatgpt.dislikemessage = async (req) => {
  let data=req.body;
  let dislikestatus = data.dislikestatus;
  let id = data.id;

  if(!id){
    reject("id id required");
      return;
  }
  if(dislikestatus){
    dislikestatus = true
  }else{
    dislikestatus = false

  }
  let userId = req.authUser ? req.authUser.userId : 0;
    if (!userId) {
      reject("login required");
      return;
    }
    // let usrdata = await UserModel.findOne({ _id: userId }).select({
    //   email:1,
    //   name:1,
    //   _id:1,
    //   dob:1,
    //   gender:1,
    //   mobileNo:1,
    //   profilePicture:1,
    //   userToken:1,
    //   status:1,
    //   feedback:1,
    //   signuptype:1,
    // }).exec();
    // if(usrdata.status != "active"){
    //   reject("User is Inactive");
    // }
    
  return new Promise((resolve, reject) => {

     HistoryModel.findOneAndUpdate(
      { _id:new ObjectId(id)  },
      {
        $set: {
          isDisLike:dislikestatus,
          updatedAt: new Date()
        }
      },
      { new: true },
      function (err, data) {
        if (err) {
          reject(err);
        } else {
          if (data) {
            resolve("Message DisLike status updated");
          } else {
            reject("Message not found");
          }
        }
      }
    );
  });
};

Chatgpt.listmessages = async (req) => {
  let data=req.body;
  let categorykey = data.categorykey;
  let currentpage = data.currentpage-1;
  let numberofdocs = data.numberofdocs;

  if (!categorykey) {
    reject("categorykey required");
    return;
  }

  if (!currentpage) {
    currentpage = 0
  }

  if (!numberofdocs) {
    numberofdocs = 10
  }

  let userId = req.authUser ? req.authUser.userId : 0;
  if (!userId) {
    reject("login required");
    return;
  }
  let usrdata = await UserModel.findOne({ _id: userId }).select({
    email:1,
    name:1,
    _id:1,
    dob:1,
    gender:1,
    mobileNo:1,
    profilePicture:1,
    userToken:1,
    status:1,
    feedback:1,
    signuptype:1,
  }).exec();
  if(usrdata.status != "active"){
    reject("User is Inactive");
  }
  
  let totalcount = await HistoryModel.find({ user_id: userId,categorykey:categorykey,status:1 }).select({
    _id:1,
  }).sort({createdAt:-1}).lean().exec();

return new Promise((resolve, reject) => {
  HistoryModel.find({ user_id: userId,categorykey:categorykey,status:1 }).select({
    _id:1,
    message:1,
    message_from:1,
    categorykey:1,
    categoryname:1,
    isLike:1,
    isDisLike:1,
    translator:1,
    isSave:1,
    status:1,
    createdAt:1
  }).sort({createdAt:-1}).skip(numberofdocs * currentpage)
  .limit(numberofdocs).lean().exec((err, res) => {
    if (err) {
      reject(err);
    } else {
      let responsedata = {
        data:res,
        totalCount:totalcount.length
      }
      resolve(responsedata);
    }
  });
});
};

Chatgpt.savedmessage = (req) => {
  let data=req.body;
  let messageid = data.messageid;

return new Promise(async (resolve, reject) => {
  let userId = req.authUser ? req.authUser.userId : 0;
  if (!userId) {
    reject("login required");
    return;
  }
  let usrdata = await UserModel.findOne({ _id: userId }).select({
    email:1,
    name:1,
    _id:1,
    dob:1,
    gender:1,
    mobileNo:1,
    profilePicture:1,
    userToken:1,
    status:1,
    feedback:1,
    signuptype:1,
  }).exec();
  if(usrdata.status != "active"){
    reject("User is Inactive");
  }
  
  if (!messageid) {
    reject("messageid required");
    return;
  }
if(ObjectId.isValid(messageid)){
  HistoryModel.find({ user_id: userId,_id:new ObjectId(messageid) }).select({
    _id:1,
    message:1,
    message_from:1,
    categoryname:1,
    user_id:1,
    categorykey:1,
    isLike:1,
    isDisLike:1,
    translator:1,
    isSave:1,
    status:1,
    createdAt:1
  }).lean().exec((err, msgres) => {
    if (err) {
      reject(err);
    } else {
      if (msgres.length > 0) {
        SavedmessageModel.find({ message_id:messageid }).select({
          _id:1,
        }).lean().exec((err, res) => { 
          if (err) {
            reject(err);
          } else {
            if (res.length == 0) {
              let savedmsgobject={
                text: msgres[0].message,
                categorykey:msgres[0].categorykey,
                categoryname:msgres[0].categoryname,
                user_id:msgres[0].user_id,
                message_id:messageid,
                isLike:msgres[0].isLike,
                isDisLike:msgres[0].isDisLike,
                isSave:true,
                translator:msgres[0].translator,
                createdAt: new Date()
              }
              SavedmessageModel.collection.insertOne(savedmsgobject,(err, data) => {
                if (err) {
                  reject(err);
                } else {
                  if (data) {
                    HistoryModel.findOneAndUpdate(
                      { _id:  new ObjectId(messageid)  },
                      {
                        $set: {
                          isSave:true,
                          updatedAt: new Date()
                        }
                      },
                      { new: true },
                      function (err, data) {
                        if (err) {
                          reject(err);
                        } else {
                          if (data) {
                            resolve("Message Saved Successfully");
                          } else {
                            reject("Message not found");
                          }
                        }
                      }
                    );
                  } else {
                    reject("Kindly try again, some error occured.");
                  }
                }
              });
            }else{
            reject("message already saved");
            }
          }
        });
      }else{
        reject("message not found");
      }
    }
  });
}else{
    reject("message id is invalid");
  }
});
};

Chatgpt.savedmessagelist = async (req) => {
  let data=req.body;
  let currentpage = data.currentpage-1;
  let numberofdocs = data.numberofdocs;

  if (!currentpage) {
    currentpage = 0
  }
  if (!numberofdocs) {
    numberofdocs = 10
  }
  let userId = req.authUser ? req.authUser.userId : 0;
  let totalcount =0
if(userId){
  totalcount = await SavedmessageModel.find({ user_id: userId }).select({
    _id:1,
  }).sort({createdAt:-1}).lean().exec();
}
return new Promise(async (resolve, reject) => {
  if (!userId) {
    reject("login required");
    return;
  }
  let usrdata = await UserModel.findOne({ _id: userId }).select({
    email:1,
    name:1,
    _id:1,
    dob:1,
    gender:1,
    mobileNo:1,
    profilePicture:1,
    userToken:1,
    status:1,
    feedback:1,
    signuptype:1,
  }).exec();
  if(usrdata.status != "active"){
    reject("User is Inactive");
  }
  
  SavedmessageModel.find({ user_id: userId }).select({
    _id :1,
    text:1,
    categorykey:1,
    categoryname:1,
    user_id:1,
    message_id:1,
    isLike:1,
    isDisLike:1,
    isSave:1,
    translator:1,
    createdAt:1,
    updatedAt:1,
  }).sort({createdAt:-1}).skip(numberofdocs * currentpage)
  .limit(numberofdocs).lean().exec((err, res) => {
    if (err) {
      reject(err);
    } else {
      let responsedata = {
        data:res,
        totalCount:totalcount.length
      }
      resolve(responsedata);
    }
  });
});
};

Chatgpt.deletesavedmessage = async (req) => {
  let message_id = req.params.message_id;
  let userId = req.authUser ? req.authUser.userId : 0;
  return new Promise(async (resolve, reject) => {
    if (!userId) {
      reject("login required");
      return;
    }
    // let usrdata = await UserModel.findOne({ _id: userId }).select({
    //   email:1,
    //   name:1,
    //   _id:1,
    //   dob:1,
    //   gender:1,
    //   mobileNo:1,
    //   profilePicture:1,
    //   userToken:1,
    //   status:1,
    //   feedback:1,
    //   signuptype:1,
    // }).exec();
    // if(usrdata.status != "active"){
    //   reject("User is Inactive");
    // }
    
    if (!message_id) {
      reject("message_id required");
      return;
    }
    if(ObjectId.isValid(message_id)){
      SavedmessageModel.deleteOne({ user_id: userId,message_id:message_id }).exec((err, res) => {
        if (err) {
          reject(err);
        } else {
          if(res.deletedCount >0){
            HistoryModel.findOneAndUpdate(
              { _id: new ObjectId(message_id)  },
              {
                $set: {
                  isSave:false,
                  updatedAt: new Date()
                }
              },
              { new: true },
              function (err, data) {
                if (err) {
                  reject(err);
                } else {
                  if (data) {
                    resolve("Saved Message deleted Successfully");
                  } else {
                    reject("Message not found");
                  }
                }
              }
            );
          }else{
            reject("Message Not in Saved list");
          }
        }
      })
    }else{
      reject("Invalid id");
    }
  });
};

Chatgpt.deletemessage = async (req) => {
  let message_id = req.params.message_id;
  let userId = req.authUser ? req.authUser.userId : 0;
  console.log("hi",userId,message_id)
  return new Promise(async (resolve, reject) => {
    if (!userId) {
      reject("login required");
      return;
    }
    // let usrdata = await UserModel.findOne({ _id: userId }).select({
    //   email:1,
    //   name:1,
    //   _id:1,
    //   dob:1,
    //   gender:1,
    //   mobileNo:1,
    //   profilePicture:1,
    //   userToken:1,
    //   status:1,
    //   feedback:1,
    //   signuptype:1,
    // }).exec();
    // if(usrdata.status != "active"){
    //   reject("User is Inactive");
    // }
    
    if (!message_id) {
      reject("message_id required");
      return;
    }
    if(ObjectId.isValid(message_id)){
      //  HistoryModel.findOneAndUpdate(
      //   { user_id: userId, _id:new ObjectId(message_id) },
      //   {
      //     $set: {
      //       status:1,
      //       // userToken:userToken-1,
      //       updatedAt: new Date()
      //     }
      //   },
      //   { new: true },
      // );

        // HistoryModel.deleteOne({ user_id: userId,_id:new ObjectId(message_id) }).exec((err, res) => {
        HistoryModel.findOneAndUpdate(
          { user_id: userId, _id:new ObjectId(message_id) },
          {
            $set: {
              status:0,
              // userToken:userToken-1,
              updatedAt: new Date()
            }
          },
          { new: true },
        ).exec((err, res) => {
        if (err) {
          reject(err);
        } else {
          if(res.status == 0){

            SavedmessageModel.deleteOne({ user_id: userId,message_id:message_id }).exec((err, resp) => {
              if (err) {
                reject(err);
              } else {
                if(resp.deletedCount >0){
                  resolve("Message Deleted.")
                }else{
                  resolve("Message Deleted.")
                }
              }
            })
          }else{
            resolve("Message Not found.")
          }
        }
      });
    }else{
      reject("Invalid Message Id");
    }
  });
};


Chatgpt.sharemessage = async (req) => {
  let message = req.body.message;
  let userId = req.authUser ? req.authUser.userId : 0;
  return new Promise(async (resolve, reject) => {
    if (!userId) {
      reject("login required");
      return;
    }
    if (!message) {
      reject("message is required");
      return;
    }
    const messageUrl = `https://yourdomain.com/shared-message?message=${encodeURIComponent(message)}`;
    if(messageUrl){

      resolve(messageUrl)
    }else{
      reject("something went wrong please try again.")
    }
  });
};

module.exports = Chatgpt;