Created
January 12, 2024 02:14
-
-
Save sendbird-community/c41b60e8ad8bceb8596baf112d3f9558 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
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