I have Integrated Google Hangout chat for node js web application.
I am able to get spaces, members in spaces, but I am not able to get Messages of space. I also referred documentation from below link
https://developers.google.com/hangouts/chat/reference/rest/v1/spaces.messages/get
Also here is discovery document:
https://chat.googleapis.com/$discovery/rest?version=v1
As per discovery document it needs {messageId} as a parameter but I am not sure where I can find/get messageId
Please find my code below:
module.exports.getMessage = async function (req, res) {
try {
let jwtClient = new google.auth.JWT(
configAuth.hangout.client_email,
null,
configAuth.hangout.private_key, ['https://www.googleapis.com/auth/chat.bot']);
const chat = google.chat({ version: 'v1', auth: jwtClient });
chat.spaces.messages.get({
name: `spaces/${req.query.spaceId}`, // here I also tried to add "/messages" but it gives 404
})
.then(result => {
return res.json({ success: true, error: false, result: result.data });
})
.catch(err => {
return res.json({ success: false, error: true, result: err });
});
} catch (error) {
return res.json({ success: false, error: true, message: error });
}
}
Please give me a solution to fetch the messages. Thanks in advance.