Edits history of script submission #4099 for ' Open a User's Profile in an Agent's Browser (zendesk)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Zendesk = {
      username: string;
      password: string;
      subdomain: string;
    };
    /**
     * Open a User's Profile in an Agent's Browser
     * Allows you to instruct an agent's browser to open a user's profile.
    
    When the message is successfully delivered to an agent's browser:
    
    ```http
    Status: 200 OK
    ```
    
    When `agent_id` or `user_id` is invalid:
    
    ```http
    Status: 404 Not Found
    ```
    
    #### Allowed For
    * Agents
     */
    export async function main(auth: Zendesk, agent_id: string, user_id: string) {
      const url = new URL(
        `https://${auth.subdomain}.zendesk.com/api/v2/channels/voice/agents/${agent_id}/users/${user_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

  • nativets
    type Zendesk = {
      username: string;
      password: string;
      subdomain: string;
    };
    /**
     * Open a User's Profile in an Agent's Browser
     * Allows you to instruct an agent's browser to open a user's profile.
    
    When the message is successfully delivered to an agent's browser:
    
    ```http
    Status: 200 OK
    ```
    
    When `agent_id` or `user_id` is invalid:
    
    ```http
    Status: 404 Not Found
    ```
    
    #### Allowed For
    * Agents
     */
    export async function main(auth: Zendesk, agent_id: string, user_id: string) {
      const url = new URL(
        `https://${auth.subdomain}.zendesk.com/api/v2/channels/voice/agents/${agent_id}/users/${user_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