Add placeholders
This commit is contained in:
parent
c745054e5a
commit
28d67ec0af
|
|
@ -100,7 +100,7 @@
|
||||||
"cid": "Emergency Announcement"
|
"cid": "Emergency Announcement"
|
||||||
},
|
},
|
||||||
"sling_chat_id": "17132563",
|
"sling_chat_id": "17132563",
|
||||||
"sling_chat_message": "A user has initiated an Emergency Announcement."
|
"sling_chat_message": "%initiatingUser% has initiated an Emergency Announcement."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "Lightning Alert",
|
"text": "Lightning Alert",
|
||||||
|
|
@ -128,7 +128,7 @@
|
||||||
"dial": "9000"
|
"dial": "9000"
|
||||||
},
|
},
|
||||||
"sling_chat_id": "17132563",
|
"sling_chat_id": "17132563",
|
||||||
"sling_chat_message": "CUDA ALERT: EAP Activation - Stand By"
|
"sling_chat_message": "CUDA ALERT: EAP Activation - Stand By - Initated by %initiatingUser%"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "EAP Evacuate",
|
"text": "EAP Evacuate",
|
||||||
|
|
@ -143,7 +143,7 @@
|
||||||
"dial": "9000"
|
"dial": "9000"
|
||||||
},
|
},
|
||||||
"sling_chat_id": "17132563",
|
"sling_chat_id": "17132563",
|
||||||
"sling_chat_message": "CUDA ALERT: EAP Activation - Evacuate"
|
"sling_chat_message": "CUDA ALERT: EAP Activation - Evacuate - Initated by %initiatingUser%"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "Fire Evac",
|
"text": "Fire Evac",
|
||||||
|
|
@ -158,7 +158,7 @@
|
||||||
"dial": "9000"
|
"dial": "9000"
|
||||||
},
|
},
|
||||||
"sling_chat_id": "17132563",
|
"sling_chat_id": "17132563",
|
||||||
"sling_chat_message": "Fire Evacuation"
|
"sling_chat_message": "Fire Evacuation Initiated by %initiatingUser%"
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@ router.post("/message", global.apiAuth, async (req, res) => {
|
||||||
return res.status(500).json({ error: "Sling token not configured" });
|
return res.status(500).json({ error: "Sling token not configured" });
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
const replacedContent = typeof content === 'string'
|
||||||
|
? content.replace(/%initiatingUser%/g, req.body.initiatingUser || '')
|
||||||
|
: content;
|
||||||
const response = await fetch(`https://api.getsling.com/v1/conversations/${channel}/messages`, {
|
const response = await fetch(`https://api.getsling.com/v1/conversations/${channel}/messages`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
|
|
@ -36,7 +39,7 @@ router.post("/message", global.apiAuth, async (req, res) => {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
'content': content
|
'content': replacedContent
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue