Sample: Send a message on Google Chat with Node `axios`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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