This repository contains sample code for the article Zendesk Sunshine Events via Webhooks published on Internal Note.
We parse an incoming post request
var payload = {
"name": "James Sullivan",
"email": "[email protected]",
"booking_id": "1345",
"date": "04/05/2023"
}
We then use the search API endpoint of Zendesk to get the user.id
of the user matching the payload.email
above.
Finally we create an event payload based on the received input data and POST
it to Zendesk.
var url = `https://${domain}.zendesk.com/api/v2/users/${user.id}/events`;
var event = {
"event": {
"source": "Website",
"type": "Booking",
"description": "✈️ New Booking",
"properties": {
"booking_id": input.booking_id,
"date": input.date
}
},
"profile": {
"identifiers": [{
"type": "email",
"value": user.email
}],
"name": user.name,
"source": "website",
"type": "customer"
}
}