@vapi-ai/web 1.0.258 → 1.0.260

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -69,6 +69,14 @@ vapi.stop();
69
69
 
70
70
  This will stop the recording and close the connection.
71
71
 
72
+ The `setMuted(muted: boolean)` can be used to mute and un-mute the user's microphone.
73
+
74
+ ```javascript
75
+ vapi.isMuted(); // false
76
+ vapi.setMuted(true);
77
+ vapi.isMuted(); // true
78
+ ```
79
+
72
80
  ## Events
73
81
 
74
82
  You can listen to the following events:
@@ -1,6 +1,6 @@
1
- import Vapi from '../vapi'; // Adjust the import path based on your project structure
1
+ import Vapi from "../vapi"; // Adjust the import path based on your project structure
2
2
 
3
- describe('Vapi', () => {
3
+ describe("Vapi", () => {
4
4
  let vapi: Vapi;
5
5
  let mockCall: any;
6
6
 
@@ -11,43 +11,46 @@ describe('Vapi', () => {
11
11
  localAudio: jest.fn(),
12
12
  };
13
13
  // Initialize Vapi instance and inject the mock
14
- vapi = new Vapi('dummy_token');
15
- vapi['call'] = mockCall; // Assuming you have a way to set this for testing
14
+ vapi = new Vapi("dummy_token");
15
+ vapi["call"] = mockCall; // Assuming you have a way to set this for testing
16
16
  });
17
17
 
18
- describe('setMuted', () => {
19
- it('should mute the audio', () => {
20
- vapi['setMuted'](true);
18
+ describe("setMuted", () => {
19
+ it("should mute the audio", () => {
20
+ vapi["setMuted"](true);
21
21
  expect(mockCall.setLocalAudio).toHaveBeenCalledWith(false);
22
22
  });
23
23
 
24
- it('should unmute the audio', () => {
25
- vapi['setMuted'](false);
24
+ it("should unmute the audio", () => {
25
+ vapi["setMuted"](false);
26
26
  expect(mockCall.setLocalAudio).toHaveBeenCalledWith(true);
27
27
  });
28
28
 
29
- it('should handle errors when call object is not available', () => {
30
- vapi['call'] = null; // Simulate call object not being available
31
- expect(() => vapi['setMuted'](true)).toThrow('Call object is not available.');
29
+ it("should handle errors when call object is not available", () => {
30
+ vapi["call"] = null; // Simulate call object not being available
31
+ expect(() => vapi["setMuted"](true)).toThrow(
32
+ "Call object is not available."
33
+ );
32
34
  });
33
35
  });
34
36
 
35
- describe('toggleMute', () => {
36
- it('should toggle audio from unmuted to muted', () => {
37
- mockCall.localAudio.mockReturnValue(true); // Initially not muted
38
- vapi.toggleMute();
39
- expect(mockCall.setLocalAudio).toHaveBeenCalledWith(false); // Should mute
37
+ describe("isMuted", () => {
38
+ it("should return false if false", () => {
39
+ mockCall.localAudio.mockReturnValue(false); // Initially not muted
40
+ const res = vapi.isMuted();
41
+ expect(res).toBe(true);
40
42
  });
41
43
 
42
- it('should toggle audio from muted to unmuted', () => {
43
- mockCall.localAudio.mockReturnValue(false); // Initially muted
44
- vapi.toggleMute();
45
- expect(mockCall.setLocalAudio).toHaveBeenCalledWith(true); // Should unmute
44
+ it("should return true if true", () => {
45
+ mockCall.localAudio.mockReturnValue(true); // Initially not muted
46
+ const res = vapi.isMuted();
47
+ expect(res).toBe(false);
46
48
  });
47
49
 
48
- it('should handle errors when call object is not available', () => {
49
- vapi['call'] = null; // Simulate call object not being available
50
- expect(() => vapi.toggleMute()).toThrow('Call object is not available.');
50
+ it("should return false if no call in progress", () => {
51
+ vapi["call"] = null; // Simulate call object not being available
52
+ const res = vapi.isMuted();
53
+ expect(res).toBe(false);
51
54
  });
52
55
  });
53
- });
56
+ });
package/api.ts CHANGED
@@ -13,7 +13,17 @@ export interface DeepgramVoice {
13
13
  /** This is the voice provider that will be used. */
14
14
  provider: "deepgram";
15
15
  /** This is the provider-specific ID that will be used. */
16
- voiceId: "asteria" | "luna" | "hera" | "athena" | "varun" | "leo" | "perseus" | "helios" | "angus" | string;
16
+ voiceId:
17
+ | "asteria"
18
+ | "luna"
19
+ | "hera"
20
+ | "athena"
21
+ | "varun"
22
+ | "leo"
23
+ | "perseus"
24
+ | "helios"
25
+ | "angus"
26
+ | string;
17
27
  }
18
28
 
19
29
  export interface OpenAIMessage {
@@ -422,7 +432,13 @@ export interface PlayHTVoice {
422
432
  * An emotion to be applied to the speech.
423
433
  * @example null
424
434
  */
425
- emotion?: "female_happy" | "female_sad" | "female_angry" | "female_fearful" | "female_disgust" | "female_surprised";
435
+ emotion?:
436
+ | "female_happy"
437
+ | "female_sad"
438
+ | "female_angry"
439
+ | "female_fearful"
440
+ | "female_disgust"
441
+ | "female_surprised";
426
442
  /**
427
443
  * A number between 1 and 6. Use lower numbers to reduce how unique your chosen voice will be compared to other voices.
428
444
  * @min 1
@@ -506,7 +522,13 @@ export interface CreateAssistantDTO {
506
522
  * These are the options for the assistant's voice.
507
523
  * @default {"provider":"playht","voiceId":"jennifer"}
508
524
  */
509
- voice?: AzureVoice | ElevenLabsVoice | PlayHTVoice | RimeAIVoice | DeepgramVoice | OpenAIVoice;
525
+ voice?:
526
+ | AzureVoice
527
+ | ElevenLabsVoice
528
+ | PlayHTVoice
529
+ | RimeAIVoice
530
+ | DeepgramVoice
531
+ | OpenAIVoice;
510
532
  /**
511
533
  * This sets the spoken language of the user. The assistant will do its best to respond in the same language.
512
534
  * When using a language other than `en-*`, only `11labs` voices will pronounce the words correctly. There will also be ~1sec of additional latency.
@@ -556,25 +578,27 @@ export interface CreateAssistantDTO {
556
578
  * These are the messages that will be sent to the Client SDKs. Default is ['transcript', 'hang', 'function-call', 'speech-update', 'metadata', 'conversation-update']
557
579
  * @example ["transcript","hang","function-call","speech-update","metadata","conversation-update"]
558
580
  */
559
- clientMessages?:
581
+ clientMessages?: (
560
582
  | "status-update"
561
583
  | "speech-update"
562
584
  | "transcript"
563
585
  | "hang"
564
586
  | "function-call"
565
587
  | "metadata"
566
- | "conversation-update";
588
+ | "conversation-update"
589
+ )[];
567
590
  /**
568
591
  * These are the messages that will be sent to your Server URL. Default is ['end-of-call-report', 'status-update', 'hang', 'function-call']
569
592
  * @example ["end-of-call-report","status-update","hang","function-call"]
570
593
  */
571
- serverMessages?:
594
+ serverMessages?: (
572
595
  | "status-update"
573
596
  | "transcript"
574
597
  | "hang"
575
598
  | "function-call"
576
599
  | "end-of-call-report"
577
- | "conversation-update";
600
+ | "conversation-update"
601
+ )[];
578
602
  /**
579
603
  * How many seconds of silence to wait before ending the call. Defaults to 30.
580
604
  * @min 10
@@ -589,6 +613,13 @@ export interface CreateAssistantDTO {
589
613
  * @example 0.4
590
614
  */
591
615
  responseDelaySeconds?: number;
616
+ /**
617
+ * This is the maximum number of seconds that the call will last. When the call reaches this duration, it will be ended.
618
+ * @min 10
619
+ * @max 3600
620
+ * @example 1800
621
+ */
622
+ maxDurationSeconds?: number;
592
623
  /**
593
624
  * This is the name of the assistant. This is just for your own reference.
594
625
  * @maxLength 100
@@ -619,6 +650,8 @@ export interface CreateAssistantDTO {
619
650
  endCallMessage?: string;
620
651
  /** This list contains phrases that, if spoken by the assistant, will trigger the call to be hung up. Case insensitive. */
621
652
  endCallPhrases?: string[];
653
+ /** This is the metadata associated with the call. */
654
+ metadata?: object;
622
655
  /**
623
656
  * This is the URL Vapi will communicate with via HTTP GET and POST Requests. This is used for retrieving context, function calling, and end-of-call reports.
624
657
  *
@@ -650,7 +683,13 @@ export interface Assistant {
650
683
  * These are the options for the assistant's voice.
651
684
  * @default {"provider":"playht","voiceId":"jennifer"}
652
685
  */
653
- voice?: AzureVoice | ElevenLabsVoice | PlayHTVoice | RimeAIVoice | DeepgramVoice | OpenAIVoice;
686
+ voice?:
687
+ | AzureVoice
688
+ | ElevenLabsVoice
689
+ | PlayHTVoice
690
+ | RimeAIVoice
691
+ | DeepgramVoice
692
+ | OpenAIVoice;
654
693
  /**
655
694
  * This sets the spoken language of the user. The assistant will do its best to respond in the same language.
656
695
  * When using a language other than `en-*`, only `11labs` voices will pronounce the words correctly. There will also be ~1sec of additional latency.
@@ -700,25 +739,27 @@ export interface Assistant {
700
739
  * These are the messages that will be sent to the Client SDKs. Default is ['transcript', 'hang', 'function-call', 'speech-update', 'metadata', 'conversation-update']
701
740
  * @example ["transcript","hang","function-call","speech-update","metadata","conversation-update"]
702
741
  */
703
- clientMessages?:
742
+ clientMessages?: (
704
743
  | "status-update"
705
744
  | "speech-update"
706
745
  | "transcript"
707
746
  | "hang"
708
747
  | "function-call"
709
748
  | "metadata"
710
- | "conversation-update";
749
+ | "conversation-update"
750
+ )[];
711
751
  /**
712
752
  * These are the messages that will be sent to your Server URL. Default is ['end-of-call-report', 'status-update', 'hang', 'function-call']
713
753
  * @example ["end-of-call-report","status-update","hang","function-call"]
714
754
  */
715
- serverMessages?:
755
+ serverMessages?: (
716
756
  | "status-update"
717
757
  | "transcript"
718
758
  | "hang"
719
759
  | "function-call"
720
760
  | "end-of-call-report"
721
- | "conversation-update";
761
+ | "conversation-update"
762
+ )[];
722
763
  /**
723
764
  * How many seconds of silence to wait before ending the call. Defaults to 30.
724
765
  * @min 10
@@ -733,6 +774,13 @@ export interface Assistant {
733
774
  * @example 0.4
734
775
  */
735
776
  responseDelaySeconds?: number;
777
+ /**
778
+ * This is the maximum number of seconds that the call will last. When the call reaches this duration, it will be ended.
779
+ * @min 10
780
+ * @max 3600
781
+ * @example 1800
782
+ */
783
+ maxDurationSeconds?: number;
736
784
  /**
737
785
  * This is the name of the assistant. This is just for your own reference.
738
786
  * @maxLength 100
@@ -763,6 +811,8 @@ export interface Assistant {
763
811
  endCallMessage?: string;
764
812
  /** This list contains phrases that, if spoken by the assistant, will trigger the call to be hung up. Case insensitive. */
765
813
  endCallPhrases?: string[];
814
+ /** This is the metadata associated with the call. */
815
+ metadata?: object;
766
816
  /**
767
817
  * This is the URL Vapi will communicate with via HTTP GET and POST Requests. This is used for retrieving context, function calling, and end-of-call reports.
768
818
  *
@@ -808,7 +858,13 @@ export interface UpdateAssistantDTO {
808
858
  * These are the options for the assistant's voice.
809
859
  * @default {"provider":"playht","voiceId":"jennifer"}
810
860
  */
811
- voice?: AzureVoice | ElevenLabsVoice | PlayHTVoice | RimeAIVoice | DeepgramVoice | OpenAIVoice;
861
+ voice?:
862
+ | AzureVoice
863
+ | ElevenLabsVoice
864
+ | PlayHTVoice
865
+ | RimeAIVoice
866
+ | DeepgramVoice
867
+ | OpenAIVoice;
812
868
  /**
813
869
  * This sets the spoken language of the user. The assistant will do its best to respond in the same language.
814
870
  * When using a language other than `en-*`, only `11labs` voices will pronounce the words correctly. There will also be ~1sec of additional latency.
@@ -858,25 +914,27 @@ export interface UpdateAssistantDTO {
858
914
  * These are the messages that will be sent to the Client SDKs. Default is ['transcript', 'hang', 'function-call', 'speech-update', 'metadata', 'conversation-update']
859
915
  * @example ["transcript","hang","function-call","speech-update","metadata","conversation-update"]
860
916
  */
861
- clientMessages?:
917
+ clientMessages?: (
862
918
  | "status-update"
863
919
  | "speech-update"
864
920
  | "transcript"
865
921
  | "hang"
866
922
  | "function-call"
867
923
  | "metadata"
868
- | "conversation-update";
924
+ | "conversation-update"
925
+ )[];
869
926
  /**
870
927
  * These are the messages that will be sent to your Server URL. Default is ['end-of-call-report', 'status-update', 'hang', 'function-call']
871
928
  * @example ["end-of-call-report","status-update","hang","function-call"]
872
929
  */
873
- serverMessages?:
930
+ serverMessages?: (
874
931
  | "status-update"
875
932
  | "transcript"
876
933
  | "hang"
877
934
  | "function-call"
878
935
  | "end-of-call-report"
879
- | "conversation-update";
936
+ | "conversation-update"
937
+ )[];
880
938
  /**
881
939
  * How many seconds of silence to wait before ending the call. Defaults to 30.
882
940
  * @min 10
@@ -891,6 +949,13 @@ export interface UpdateAssistantDTO {
891
949
  * @example 0.4
892
950
  */
893
951
  responseDelaySeconds?: number;
952
+ /**
953
+ * This is the maximum number of seconds that the call will last. When the call reaches this duration, it will be ended.
954
+ * @min 10
955
+ * @max 3600
956
+ * @example 1800
957
+ */
958
+ maxDurationSeconds?: number;
894
959
  /**
895
960
  * This is the name of the assistant. This is just for your own reference.
896
961
  * @maxLength 100
@@ -921,6 +986,8 @@ export interface UpdateAssistantDTO {
921
986
  endCallMessage?: string;
922
987
  /** This list contains phrases that, if spoken by the assistant, will trigger the call to be hung up. Case insensitive. */
923
988
  endCallPhrases?: string[];
989
+ /** This is the metadata associated with the call. */
990
+ metadata?: object;
924
991
  /**
925
992
  * This is the URL Vapi will communicate with via HTTP GET and POST Requests. This is used for retrieving context, function calling, and end-of-call reports.
926
993
  *
@@ -1706,16 +1773,22 @@ export interface FullRequestParams extends Omit<RequestInit, "body"> {
1706
1773
  cancelToken?: CancelToken;
1707
1774
  }
1708
1775
 
1709
- export type RequestParams = Omit<FullRequestParams, "body" | "method" | "query" | "path">;
1776
+ export type RequestParams = Omit<
1777
+ FullRequestParams,
1778
+ "body" | "method" | "query" | "path"
1779
+ >;
1710
1780
 
1711
1781
  export interface ApiConfig<SecurityDataType = unknown> {
1712
1782
  baseUrl?: string;
1713
1783
  baseApiParams?: Omit<RequestParams, "baseUrl" | "cancelToken" | "signal">;
1714
- securityWorker?: (securityData: SecurityDataType | null) => Promise<RequestParams | void> | RequestParams | void;
1784
+ securityWorker?: (
1785
+ securityData: SecurityDataType | null
1786
+ ) => Promise<RequestParams | void> | RequestParams | void;
1715
1787
  customFetch?: typeof fetch;
1716
1788
  }
1717
1789
 
1718
- export interface HttpResponse<D extends unknown, E extends unknown = unknown> extends Response {
1790
+ export interface HttpResponse<D extends unknown, E extends unknown = unknown>
1791
+ extends Response {
1719
1792
  data: D;
1720
1793
  error: E;
1721
1794
  }
@@ -1734,7 +1807,8 @@ export class HttpClient<SecurityDataType = unknown> {
1734
1807
  private securityData: SecurityDataType | null = null;
1735
1808
  private securityWorker?: ApiConfig<SecurityDataType>["securityWorker"];
1736
1809
  private abortControllers = new Map<CancelToken, AbortController>();
1737
- private customFetch = (...fetchParams: Parameters<typeof fetch>) => fetch(...fetchParams);
1810
+ private customFetch = (...fetchParams: Parameters<typeof fetch>) =>
1811
+ fetch(...fetchParams);
1738
1812
 
1739
1813
  private baseApiParams: RequestParams = {
1740
1814
  credentials: "same-origin",
@@ -1753,7 +1827,9 @@ export class HttpClient<SecurityDataType = unknown> {
1753
1827
 
1754
1828
  protected encodeQueryParam(key: string, value: any) {
1755
1829
  const encodedKey = encodeURIComponent(key);
1756
- return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`;
1830
+ return `${encodedKey}=${encodeURIComponent(
1831
+ typeof value === "number" ? value : `${value}`
1832
+ )}`;
1757
1833
  }
1758
1834
 
1759
1835
  protected addQueryParam(query: QueryParamsType, key: string) {
@@ -1767,9 +1843,15 @@ export class HttpClient<SecurityDataType = unknown> {
1767
1843
 
1768
1844
  protected toQueryString(rawQuery?: QueryParamsType): string {
1769
1845
  const query = rawQuery || {};
1770
- const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]);
1846
+ const keys = Object.keys(query).filter(
1847
+ (key) => "undefined" !== typeof query[key]
1848
+ );
1771
1849
  return keys
1772
- .map((key) => (Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key)))
1850
+ .map((key) =>
1851
+ Array.isArray(query[key])
1852
+ ? this.addArrayQueryParam(query, key)
1853
+ : this.addQueryParam(query, key)
1854
+ )
1773
1855
  .join("&");
1774
1856
  }
1775
1857
 
@@ -1780,8 +1862,13 @@ export class HttpClient<SecurityDataType = unknown> {
1780
1862
 
1781
1863
  private contentFormatters: Record<ContentType, (input: any) => any> = {
1782
1864
  [ContentType.Json]: (input: any) =>
1783
- input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
1784
- [ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
1865
+ input !== null && (typeof input === "object" || typeof input === "string")
1866
+ ? JSON.stringify(input)
1867
+ : input,
1868
+ [ContentType.Text]: (input: any) =>
1869
+ input !== null && typeof input !== "string"
1870
+ ? JSON.stringify(input)
1871
+ : input,
1785
1872
  [ContentType.FormData]: (input: any) =>
1786
1873
  Object.keys(input || {}).reduce((formData, key) => {
1787
1874
  const property = input[key];
@@ -1791,14 +1878,17 @@ export class HttpClient<SecurityDataType = unknown> {
1791
1878
  ? property
1792
1879
  : typeof property === "object" && property !== null
1793
1880
  ? JSON.stringify(property)
1794
- : `${property}`,
1881
+ : `${property}`
1795
1882
  );
1796
1883
  return formData;
1797
1884
  }, new FormData()),
1798
1885
  [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input),
1799
1886
  };
1800
1887
 
1801
- protected mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams {
1888
+ protected mergeRequestParams(
1889
+ params1: RequestParams,
1890
+ params2?: RequestParams
1891
+ ): RequestParams {
1802
1892
  return {
1803
1893
  ...this.baseApiParams,
1804
1894
  ...params1,
@@ -1811,7 +1901,9 @@ export class HttpClient<SecurityDataType = unknown> {
1811
1901
  };
1812
1902
  }
1813
1903
 
1814
- protected createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => {
1904
+ protected createAbortSignal = (
1905
+ cancelToken: CancelToken
1906
+ ): AbortSignal | undefined => {
1815
1907
  if (this.abortControllers.has(cancelToken)) {
1816
1908
  const abortController = this.abortControllers.get(cancelToken);
1817
1909
  if (abortController) {
@@ -1855,15 +1947,28 @@ export class HttpClient<SecurityDataType = unknown> {
1855
1947
  const payloadFormatter = this.contentFormatters[type || ContentType.Json];
1856
1948
  const responseFormat = format || requestParams.format;
1857
1949
 
1858
- return this.customFetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, {
1859
- ...requestParams,
1860
- headers: {
1861
- ...(requestParams.headers || {}),
1862
- ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}),
1863
- },
1864
- signal: (cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal) || null,
1865
- body: typeof body === "undefined" || body === null ? null : payloadFormatter(body),
1866
- }).then(async (response) => {
1950
+ return this.customFetch(
1951
+ `${baseUrl || this.baseUrl || ""}${path}${
1952
+ queryString ? `?${queryString}` : ""
1953
+ }`,
1954
+ {
1955
+ ...requestParams,
1956
+ headers: {
1957
+ ...(requestParams.headers || {}),
1958
+ ...(type && type !== ContentType.FormData
1959
+ ? { "Content-Type": type }
1960
+ : {}),
1961
+ },
1962
+ signal:
1963
+ (cancelToken
1964
+ ? this.createAbortSignal(cancelToken)
1965
+ : requestParams.signal) || null,
1966
+ body:
1967
+ typeof body === "undefined" || body === null
1968
+ ? null
1969
+ : payloadFormatter(body),
1970
+ }
1971
+ ).then(async (response) => {
1867
1972
  const r = response as HttpResponse<T, E>;
1868
1973
  r.data = null as unknown as T;
1869
1974
  r.error = null as unknown as E;
@@ -1902,7 +2007,9 @@ export class HttpClient<SecurityDataType = unknown> {
1902
2007
  *
1903
2008
  * API for building voice assistants
1904
2009
  */
1905
- export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDataType> {
2010
+ export class Api<
2011
+ SecurityDataType extends unknown,
2012
+ > extends HttpClient<SecurityDataType> {
1906
2013
  assistant = {
1907
2014
  /**
1908
2015
  * No description
@@ -1913,7 +2020,10 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
1913
2020
  * @request POST:/assistant
1914
2021
  * @secure
1915
2022
  */
1916
- assistantControllerCreate: (data: CreateAssistantDTO, params: RequestParams = {}) =>
2023
+ assistantControllerCreate: (
2024
+ data: CreateAssistantDTO,
2025
+ params: RequestParams = {}
2026
+ ) =>
1917
2027
  this.request<Assistant, any>({
1918
2028
  path: `/assistant`,
1919
2029
  method: "POST",
@@ -1982,7 +2092,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
1982
2092
  */
1983
2093
  updatedAtLe?: string;
1984
2094
  },
1985
- params: RequestParams = {},
2095
+ params: RequestParams = {}
1986
2096
  ) =>
1987
2097
  this.request<Assistant[], any>({
1988
2098
  path: `/assistant`,
@@ -2020,7 +2130,11 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2020
2130
  * @request PATCH:/assistant/{id}
2021
2131
  * @secure
2022
2132
  */
2023
- assistantControllerUpdate: (id: string, data: UpdateAssistantDTO, params: RequestParams = {}) =>
2133
+ assistantControllerUpdate: (
2134
+ id: string,
2135
+ data: UpdateAssistantDTO,
2136
+ params: RequestParams = {}
2137
+ ) =>
2024
2138
  this.request<Assistant, any>({
2025
2139
  path: `/assistant/${id}`,
2026
2140
  method: "PATCH",
@@ -2040,7 +2154,11 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2040
2154
  * @request PUT:/assistant/{id}
2041
2155
  * @secure
2042
2156
  */
2043
- assistantControllerReplace: (id: string, data: UpdateAssistantDTO, params: RequestParams = {}) =>
2157
+ assistantControllerReplace: (
2158
+ id: string,
2159
+ data: UpdateAssistantDTO,
2160
+ params: RequestParams = {}
2161
+ ) =>
2044
2162
  this.request<Assistant, any>({
2045
2163
  path: `/assistant/${id}`,
2046
2164
  method: "PUT",
@@ -2130,7 +2248,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2130
2248
  */
2131
2249
  updatedAtLe?: string;
2132
2250
  },
2133
- params: RequestParams = {},
2251
+ params: RequestParams = {}
2134
2252
  ) =>
2135
2253
  this.request<Call[], any>({
2136
2254
  path: `/call`,
@@ -2168,7 +2286,10 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2168
2286
  * @request POST:/call/phone
2169
2287
  * @secure
2170
2288
  */
2171
- callControllerCreatePhoneCall: (data: CreateOutboundCallDTO, params: RequestParams = {}) =>
2289
+ callControllerCreatePhoneCall: (
2290
+ data: CreateOutboundCallDTO,
2291
+ params: RequestParams = {}
2292
+ ) =>
2172
2293
  this.request<Call, any>({
2173
2294
  path: `/call/phone`,
2174
2295
  method: "POST",
@@ -2188,7 +2309,10 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2188
2309
  * @request POST:/call/web
2189
2310
  * @secure
2190
2311
  */
2191
- callControllerCreateWebCall: (data: CreateWebCallDTO, params: RequestParams = {}) =>
2312
+ callControllerCreateWebCall: (
2313
+ data: CreateWebCallDTO,
2314
+ params: RequestParams = {}
2315
+ ) =>
2192
2316
  this.request<Call, any>({
2193
2317
  path: `/call/web`,
2194
2318
  method: "POST",
@@ -2250,7 +2374,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2250
2374
  | ({
2251
2375
  provider: "runpod";
2252
2376
  } & CreateRunpodCredentialDTO),
2253
- params: RequestParams = {},
2377
+ params: RequestParams = {}
2254
2378
  ) =>
2255
2379
  this.request<
2256
2380
  | ({
@@ -2361,7 +2485,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2361
2485
  */
2362
2486
  updatedAtLe?: string;
2363
2487
  },
2364
- params: RequestParams = {},
2488
+ params: RequestParams = {}
2365
2489
  ) =>
2366
2490
  this.request<
2367
2491
  (
@@ -2525,7 +2649,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2525
2649
  | ({
2526
2650
  provider: "runpod";
2527
2651
  } & UpdateRunpodCredentialDTO),
2528
- params: RequestParams = {},
2652
+ params: RequestParams = {}
2529
2653
  ) =>
2530
2654
  this.request<
2531
2655
  | ({
@@ -2647,7 +2771,10 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2647
2771
  * @request POST:/phone-number/buy
2648
2772
  * @secure
2649
2773
  */
2650
- phoneNumberControllerBuy: (data: BuyPhoneNumberDTO, params: RequestParams = {}) =>
2774
+ phoneNumberControllerBuy: (
2775
+ data: BuyPhoneNumberDTO,
2776
+ params: RequestParams = {}
2777
+ ) =>
2651
2778
  this.request<PhoneNumber, any>({
2652
2779
  path: `/phone-number/buy`,
2653
2780
  method: "POST",
@@ -2667,7 +2794,10 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2667
2794
  * @request POST:/phone-number/import
2668
2795
  * @secure
2669
2796
  */
2670
- phoneNumberControllerImport: (data: ImportTwilioPhoneNumberDTO, params: RequestParams = {}) =>
2797
+ phoneNumberControllerImport: (
2798
+ data: ImportTwilioPhoneNumberDTO,
2799
+ params: RequestParams = {}
2800
+ ) =>
2671
2801
  this.request<PhoneNumber, any>({
2672
2802
  path: `/phone-number/import`,
2673
2803
  method: "POST",
@@ -2736,7 +2866,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2736
2866
  */
2737
2867
  updatedAtLe?: string;
2738
2868
  },
2739
- params: RequestParams = {},
2869
+ params: RequestParams = {}
2740
2870
  ) =>
2741
2871
  this.request<PhoneNumber[], any>({
2742
2872
  path: `/phone-number`,
@@ -2774,7 +2904,11 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2774
2904
  * @request PATCH:/phone-number/{id}
2775
2905
  * @secure
2776
2906
  */
2777
- phoneNumberControllerUpdate: (id: string, data: UpdatePhoneNumberDTO, params: RequestParams = {}) =>
2907
+ phoneNumberControllerUpdate: (
2908
+ id: string,
2909
+ data: UpdatePhoneNumberDTO,
2910
+ params: RequestParams = {}
2911
+ ) =>
2778
2912
  this.request<PhoneNumber, any>({
2779
2913
  path: `/phone-number/${id}`,
2780
2914
  method: "PATCH",
@@ -2830,7 +2964,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2830
2964
  */
2831
2965
  rangeEnd?: string;
2832
2966
  },
2833
- params: RequestParams = {},
2967
+ params: RequestParams = {}
2834
2968
  ) =>
2835
2969
  this.request<Metrics[], any>({
2836
2970
  path: `/metrics`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vapi-ai/web",
3
- "version": "1.0.258",
3
+ "version": "1.0.260",
4
4
  "description": "",
5
5
  "main": "dist/vapi.js",
6
6
  "types": "dist/vapi.d.ts",
package/vapi.ts CHANGED
@@ -178,7 +178,7 @@ export default class Vapi extends VapiEventEmitter {
178
178
  });
179
179
 
180
180
  this.call.startRemoteParticipantsAudioLevelObserver(100);
181
-
181
+
182
182
  this.call.on("remote-participants-audio-level", (e) => {
183
183
  if (e) this.handleRemoteParticipantsAudioLevel(e);
184
184
  });
@@ -212,7 +212,7 @@ export default class Vapi extends VapiEventEmitter {
212
212
  const parsedMessage = JSON.parse(e.data);
213
213
  this.emit("message", parsedMessage);
214
214
  } catch (parseError) {
215
- console.log("Error parsing message data: ", parseError);
215
+ console.log("Error parsing message data: ", parseError);
216
216
  }
217
217
  }
218
218
  } catch (e) {
@@ -257,28 +257,25 @@ export default class Vapi extends VapiEventEmitter {
257
257
  this.call?.sendAppMessage(JSON.stringify(message));
258
258
  }
259
259
 
260
- private setMuted(mute: boolean) {
260
+ public setMuted(mute: boolean) {
261
261
  try {
262
262
  if (!this.call) {
263
- throw new Error('Call object is not available.');
263
+ throw new Error("Call object is not available.");
264
264
  }
265
265
  this.call.setLocalAudio(!mute);
266
266
  } catch (error) {
267
- console.error("Error in setMuted:", error);
268
267
  throw error;
269
268
  }
270
269
  }
271
270
 
272
- public toggleMute() {
271
+ public isMuted() {
273
272
  try {
274
273
  if (!this.call) {
275
- throw new Error('Call object is not available.');
274
+ return false;
276
275
  }
277
- const isCurrentlyMuted = this.call.localAudio() === false;
278
- this.setMuted(!isCurrentlyMuted);
276
+ return this.call.localAudio() === false;
279
277
  } catch (error) {
280
- console.error("Error in toggleMute:", error);
281
- throw error;
278
+ throw error;
282
279
  }
283
- }
280
+ }
284
281
  }