Skip to content

Instantly share code, notes, and snippets.

@gh640

gh640/card.js

Created Apr 25, 2021
Embed
What would you like to do?
Sample: Send a message on Google Chat with Node `axios`
const axios = require(`axios`)
// Pass incoming webhook URL with environment variable `WEBHOOK_URL`.
const WEBHOOK_URL = process.env.WEBHOOK_URL
const title = `Hi`
const subtitle = `Hello`
const paragraph = `Hasta La Vista, Baby.`
const widget = { textParagraph: { text: paragraph } }
axios.post(WEBHOOK_URL, {
cards: [
{
header: {
title: title,
subtitle, subtitle,
},
sections: [
{
widgets: [widget],
},
],
},
],
})
.then((res) => {
console.log(res)
})
.catch((err) => {
console.error(err.toJSON())
})
const axios = require(`axios`)
// Pass incoming webhook URL with environment variable `WEBHOOK_URL`.
const WEBHOOK_URL = process.env.WEBHOOK_URL
const text = `Hello`
axios.post(WEBHOOK_URL, {
text: text,
})
.then((res) => {
console.log(res)
})
.catch((err) => {
console.error(err.toJSON())
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment