type Zendesk = {
username: string;
password: string;
subdomain: string;
};
/**
* Open Ticket in Agent's Browser
* Allows you to instruct an agent's browser to open a ticket.
When the message is successfully delivered to an agent's browser:
```http
Status: 200 OK
```
When `agent_id` or `ticket_id` is invalid:
```http
Status: 404 Not Found
```
#### Allowed For
* Agents
*/
export async function main(auth: Zendesk, agent_id: string, ticket_id: string) {
const url = new URL(
`https://${auth.subdomain}.zendesk.com/api/v2/channels/voice/agents/${agent_id}/tickets/${ticket_id}/display`
);
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 377 days ago
type Zendesk = {
username: string;
password: string;
subdomain: string;
};
/**
* Open Ticket in Agent's Browser
* Allows you to instruct an agent's browser to open a ticket.
When the message is successfully delivered to an agent's browser:
```http
Status: 200 OK
```
When `agent_id` or `ticket_id` is invalid:
```http
Status: 404 Not Found
```
#### Allowed For
* Agents
*/
export async function main(auth: Zendesk, agent_id: string, ticket_id: string) {
const url = new URL(
`https://${auth.subdomain}.zendesk.com/api/v2/channels/voice/agents/${agent_id}/tickets/${ticket_id}/display`
);
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 923 days ago