Edits history of script submission #16734 for ' Set chat settings (kustomer)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Kustomer = {
      apiKey: string;
    };
    /**
     * Set chat settings
     * Sets the display options for the chat channel.
    
    Any one of the following roles is required for this endpoint:
    
    |Legacy Role|Equivalent Permission Set Role|
    |-----|--------|
    |org.admin.apps.write|org.permission.apps.update|
     */
    export async function main(
      auth: Kustomer,
      body: {
        teamName?: string;
        teamIconUrl?: string;
        greeting?: string;
        autoreply?: string;
        embedIconUrl?: string;
        embedIconColor?: string;
        fallbackFromEmail?: string;
        offhoursDisplay?: "online" | "offline" | "none";
        offhoursMessage?: string;
        offhoursImageUrl?: string;
        volumeControl?: {
          enabled?: false | true;
          mode?: "delayed" | "upfront";
          markDoneAfterTimeout?: false | true;
          useDynamicWaitMessage?: false | true;
          promptDelay?: number;
          upfrontWaitThreshold?: number;
          timeout?: number;
          followUpChannels?: "email" | "sms" | "voice"[];
          hideWaitOption?: false | true;
          customWaitMessage?: string;
        };
        singleSessionChat?: false | true;
        closableChat?: false | true;
        noHistory?: false | true;
        activeForm?: string;
        domainCriteria?: { and?: {}[]; or?: {}[] };
        enabled?: false | true;
        showBrandingIdentifier?: false | true;
        showTypingIndicatorWeb?: false | true;
        showTypingIndicatorCustomerWeb?: false | true;
      },
    ) {
      const url = new URL(`https://api.kustomerapp.com/v1/chat/settings`);
    
      const response = await fetch(url, {
        method: "PATCH",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.apiKey,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 235 days ago