function notifyTeamMembersOfNewRequest(event) {
const response = event.values
console.log(`response values: ${response}`)
let payload = {
text: response,
channel: 'C04AZ4GT2UU'
}
requestSlack('POST', `chat.postMessage`, payload)
}
function requestSlack(method, endpoint, params) {
const headers = {
'Authorization': "Bearer " + 'xoxb-85054344165-4375824305110-C3V8yq8xiLfNyghxWyQHPZVG',
'Content-Type' : 'application/json'
}
const options = {
headers: headers,
method: method
}
let request_url
if (method == 'POST') {
request_url = base_url + endpoint
options.payload = JSON.stringify(params)
} else {
request_url = base_url + endpoint + params
}
const response = UrlFetchApp.fetch(request_url, options).getContentText();
const json = JSON.parse(response)
return {
response_code: json.ok,
response_data: json
}
}