Skip to content

Instantly share code, notes, and snippets.

@sendbird-community
Created January 12, 2024 02:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sendbird-community/c41b60e8ad8bceb8596baf112d3f9558 to your computer and use it in GitHub Desktop.
Save sendbird-community/c41b60e8ad8bceb8596baf112d3f9558 to your computer and use it in GitHub Desktop.
async function updateTicketStatus (channelUrl) {
try {
const ticket = await axios.get(`https://desk-api-${APP_ID}.sendbird.com/platform/v1/tickets?channel_url=${channelUrl}`, {
headers: {
"Content-Type": "application/json; charset=utf8",
"SENDBIRDDESKAPITOKEN": SENDBIRDDESKAPITOKEN
}
})
const ticketId = ticket.data.results[0].id
const ticketUpdate = await axios.patch(`https://desk-api-${APP_ID}.sendbird.com/platform/v1/tickets/${ticketId}`,{
"priority": "HIGH"}, {
headers: {
"Content-Type": "application/json; charset=utf8",
"SENDBIRDDESKAPITOKEN": SENDBIRDDESKAPITOKEN
}
})
const assignGroup = await axios.post(`https://desk-api-${APP_ID}.sendbird.com/platform/v1/tickets/transfer_to_group`,{
"tickets": [ticketId],
"status": "PENDING",
"groupKey":"example1"
}, {
headers: {
"Content-Type": "application/json; charset=utf8",
"SENDBIRDDESKAPITOKEN": SENDBIRDDESKAPITOKEN
}
})
return { success: true, message: 'Ticket updated successfully' };
} catch (e) {
console.log(e)
return { success: false, message: 'Failed to update ticket' };
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment