I’m trying to create a workflow where when a quote is signed, it sends a webhook POST to a Google Chat space with a message saying something like “[Quote Title] has been signed”
I have the webhook url for the Google Chat space i need to post to, but when i try and test it out, i get an error saying “invalid json payload format”
I’m wondering if anyone has tried sending such messages to Google Chat, and what settings do i need to use to make it work.
Hi @mohamedhamad, thank you for posting in our Community!
Please, can you ensure that the payload you are sending is in the correct JSON format that Google Chat expects? Google Chat expects a specific structure for the messages it receives
To our top experts, @Anton @SteveHTM @zach_threadint any recommendations for @mohamedhamad?
Thank you,
Pam
Hi @mohamedhamad 
(thanks for the nudge, @PamCotton)
Are you sending the HubSpot Workflow webhook directly to Google Chat? If so, I think you’ll need to create some middleware to [1] process the webhook from HubSpot and then [2] pass that data to Google Chat in the expected format. If you haven’t already, I’d recommend reading this Google documentation.
I hope this proves useful. Please let me know if you have any follow-up questions.
i’m trying to use either NodeJs or Python and testing out the sample script from google on how to send to google chat space. unfortunatley, for JS, fetch is not an available library, and for python, Http is not available either.
not sure how i can format the body in the right json format either. not a lot of options in the webhook action.
this is usually pretty simple, in that systems i’ve worked with have the body wrapped as a serialized json object. but for some reason the webhook action doesnt do that
So i figued it out. this code works for me. Parking it here incase anyone else wants to use this.
Its a basic message that sends a card view.
const axios = require(`axios`);
exports.main = async (event, callback) => {
/*****
Use inputs to get data from any action in your workflow and use it in your code instead of having to use the HubSpot API.
*****/
const email = event.inputFields["email"];
// Get the webhook url from Google Chat
const webhook_url =
"https://chat.googleapis.com/v1/spaces/....../messages?key=XXXXXX&token=XXXXXXXX";
const title = "Hi";
const subtitle = "Hello";
const paragraph = "Hasta La Vista, Baby.";
const widget = { textParagraph: { text: paragraph } };
/*****
Use the callback function to output data that can be used in later actions in your workflow.
*****/
axios
.post(webhook_url, {
cards: [
{
header: {
title: title,
subtitle: subtitle,
},
sections: [
{
widgets: [widget],
},
],
},
],
})
.then((res) => {
console.log(res);
})
.catch((err) => {
console.error(err.toJSON());
});
callback({
outputFields: {
email: email,
},
});
};