-
-
Save jetaggart/6f1d03728d639e7e132e7046d4f916ff to your computer and use it in GitHub Desktop.
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
// backend/server.js:33 | |
app.post('/messages', async (req, res) => { | |
try { | |
const leadId = req.body.leadId; | |
let previousTranscript = await getPreviousTranscript(leadId); | |
const payload = { | |
'description': `${previousTranscript}\n${req.body.author}: ${req.body.message.text}` | |
} | |
const headers = { | |
'Accept': 'application/json', | |
'Content-Type': 'application/json', | |
'Authorization': `Bearer ${process.env.ZENDESK_CRM_TOKEN}` | |
} | |
await axios.put( | |
'https://api.getbase.com/v2/leads/' + leadId, | |
{ data: payload }, | |
{ headers: headers } | |
); | |
res.send({}); | |
} catch (err) { | |
console.log(err); | |
res.status(500); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment