//native
/**
* Reply to Side Conversation
* Reply to a ticket's side conversation. `to` takes the same participant objects as Create Side Conversation, e.g. `[{ "email": "person@example.com" }]`.
*/
export async function main(
auth: RT.Zendesk,
ticket_id: number,
side_conversation_id: string,
body: string,
to: { [key: string]: any }[],
subject: string | undefined
) {
const response = await fetch(
`https://${auth.subdomain}.zendesk.com/api/v2/tickets/${ticket_id}/side_conversations/${side_conversation_id}/reply`,
{
method: "POST",
headers: {
Authorization: auth.token
? `Bearer ${auth.token}`
: `Basic ${btoa(`${auth.username}:${auth.password}`)}`,
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({
message: { subject: subject || undefined, body, to },
}),
}
)
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 2 hours ago