@capawesome/capacitor-vapi
v5.0.0-dev.25c9a34.1728154031
Published
Unofficial Capacitor plugin for Vapi SDK.
Readme
@capawesome/capacitor-vapi
Unofficial Capacitor plugin for Vapi.[^1]
Installation
npm install @capawesome/capacitor-vapi @vapi-ai/web openai
npx cap syncAndroid
Variables
This plugin will use the following project variables (defined in your app’s variables.gradle file):
$androidxCoreKtxVersionversion ofandroidx.core:core-ktx(default:1.13.1)
iOS
Add the NSMicrophoneUsageDescription, NSCameraUsageDescription and UIBackgroundModes keys to the Info.plist file (usually ios/App/App/Info.plist), which tells the user why your app needs access to the microphone and camera, and that it needs to run in the background:
<key>NSMicrophoneUsageDescription</key>
<string>The app needs access to the microphone to record audio.</string>
<key>NSCameraUsageDescription</key>
<string>The app needs access to the camera to record video.</string>
<key>UIBackgroundModes</key>
<array>
<string>voip</string>
<string>audio</string>
</array>Configuration
No configuration required for this plugin.
Usage
import { Vapi } from '@capawesome/capacitor-vapi';
const echo = async () => {
await Vapi.echo();
};API
isMuted()say(...)setMuted(...)setup(...)start(...)stop()addListener('callEnd', ...)addListener('callStart', ...)addListener('conversationUpdate', ...)addListener('error', ...)addListener('speechUpdate', ...)removeAllListeners()- Interfaces
- Type Aliases
isMuted()
isMuted() => Promise<IsMutedResult>Returns: Promise<IsMutedResult>
say(...)
say(options: SayOptions) => Promise<void>| Param | Type |
| ------------- | ------------------------------------------------- |
| options | SayOptions |
setMuted(...)
setMuted(options: SetMutedOptions) => Promise<void>| Param | Type |
| ------------- | ----------------------------------------------------------- |
| options | SetMutedOptions |
setup(...)
setup(options: SetupOptions) => Promise<void>| Param | Type |
| ------------- | ----------------------------------------------------- |
| options | SetupOptions |
start(...)
start(options: StartOptions) => Promise<void>| Param | Type |
| ------------- | ----------------------------------------------------- |
| options | StartOptions |
stop()
stop() => Promise<void>addListener('callEnd', ...)
addListener(eventName: 'callEnd', listenerFunc: CallEndEventListener) => Promise<PluginListenerHandle>| Param | Type |
| ------------------ | --------------------------------------------------------------------- |
| eventName | 'callEnd' |
| listenerFunc | CallEndEventListener |
Returns: Promise<PluginListenerHandle>
addListener('callStart', ...)
addListener(eventName: 'callStart', listenerFunc: CallStartEventListener) => Promise<PluginListenerHandle>| Param | Type |
| ------------------ | ------------------------------------------------------------------------- |
| eventName | 'callStart' |
| listenerFunc | CallStartEventListener |
Returns: Promise<PluginListenerHandle>
addListener('conversationUpdate', ...)
addListener(eventName: 'conversationUpdate', listenerFunc: ConversationUpdateEventListener) => Promise<PluginListenerHandle>| Param | Type |
| ------------------ | ------------------------------------------------------------------------------------------- |
| eventName | 'conversationUpdate' |
| listenerFunc | ConversationUpdateEventListener |
Returns: Promise<PluginListenerHandle>
addListener('error', ...)
addListener(eventName: 'error', listenerFunc: ErrorEventListener) => Promise<PluginListenerHandle>| Param | Type |
| ------------------ | ----------------------------------------------------------------- |
| eventName | 'error' |
| listenerFunc | ErrorEventListener |
Returns: Promise<PluginListenerHandle>
addListener('speechUpdate', ...)
addListener(eventName: 'speechUpdate', listenerFunc: SpeechUpdateEventListener) => Promise<PluginListenerHandle>| Param | Type |
| ------------------ | ------------------------------------------------------------------------------- |
| eventName | 'speechUpdate' |
| listenerFunc | SpeechUpdateEventListener |
Returns: Promise<PluginListenerHandle>
removeAllListeners()
removeAllListeners() => Promise<void>Remove all listeners for this plugin.
Interfaces
IsMutedResult
| Prop | Type |
| ----------- | -------------------- |
| muted | boolean |
SayOptions
| Prop | Type | Description |
| ------------------------ | -------------------- | ---------------------- |
| message | string | |
| endCallAfterSpoken | boolean | Only available on Web. |
SetMutedOptions
| Prop | Type |
| ----------- | -------------------- |
| muted | boolean |
SetupOptions
| Prop | Type |
| ------------ | ------------------- |
| apiKey | string |
StartOptions
| Prop | Type |
| ----------------- | ------------------- |
| assistantId | string |
PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove | () => Promise<void> |
ConversationUpdateEvent
| Prop | Type |
| -------------- | ---------------------------------------------------------------------------- |
| messages | { content: string; role: 'user' | 'assistant' | 'system'; }[] |
ErrorEvent
Events providing information related to errors in scripts or in files.
| Prop | Type |
| -------------- | ------------------- |
| colno | number |
| error | any |
| filename | string |
| lineno | number |
| message | string |
SpeechUpdateEvent
| Prop | Type | Description |
| ------------ | ----------------------------------- | ---------------------------------- |
| role | 'user' | 'assistant' | Only available on Android and iOS. |
| status | 'stopped' | 'started' | |
Type Aliases
CallEndEventListener
(): void
CallStartEventListener
(): void
ConversationUpdateEventListener
(event: ConversationUpdateEvent): void
ErrorEventListener
(error: ErrorEvent): void
SpeechUpdateEventListener
(event: SpeechUpdateEvent): void
Changelog
See CHANGELOG.md.
License
See LICENSE.
[^1]: This project is not affiliated with, endorsed by, sponsored by, or approved by Superpowered Labs Inc. or any of their affiliates or subsidiaries.
