5.0.0-dev.25c9a34.1728154031 • Published 10 months ago

@capawesome/capacitor-vapi v5.0.0-dev.25c9a34.1728154031

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@capawesome/capacitor-vapi

Unofficial Capacitor plugin for Vapi.^1

Installation

npm install @capawesome/capacitor-vapi @vapi-ai/web openai
npx cap sync

Android

Variables

This plugin will use the following project variables (defined in your app’s variables.gradle file):

  • $androidxCoreKtxVersion version of androidx.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()

isMuted() => Promise<IsMutedResult>

Returns: Promise<IsMutedResult>


say(...)

say(options: SayOptions) => Promise<void>
ParamType
optionsSayOptions

setMuted(...)

setMuted(options: SetMutedOptions) => Promise<void>
ParamType
optionsSetMutedOptions

setup(...)

setup(options: SetupOptions) => Promise<void>
ParamType
optionsSetupOptions

start(...)

start(options: StartOptions) => Promise<void>
ParamType
optionsStartOptions

stop()

stop() => Promise<void>

addListener('callEnd', ...)

addListener(eventName: 'callEnd', listenerFunc: CallEndEventListener) => Promise<PluginListenerHandle>
ParamType
eventName'callEnd'
listenerFuncCallEndEventListener

Returns: Promise<PluginListenerHandle>


addListener('callStart', ...)

addListener(eventName: 'callStart', listenerFunc: CallStartEventListener) => Promise<PluginListenerHandle>
ParamType
eventName'callStart'
listenerFuncCallStartEventListener

Returns: Promise<PluginListenerHandle>


addListener('conversationUpdate', ...)

addListener(eventName: 'conversationUpdate', listenerFunc: ConversationUpdateEventListener) => Promise<PluginListenerHandle>
ParamType
eventName'conversationUpdate'
listenerFuncConversationUpdateEventListener

Returns: Promise<PluginListenerHandle>


addListener('error', ...)

addListener(eventName: 'error', listenerFunc: ErrorEventListener) => Promise<PluginListenerHandle>
ParamType
eventName'error'
listenerFuncErrorEventListener

Returns: Promise<PluginListenerHandle>


addListener('speechUpdate', ...)

addListener(eventName: 'speechUpdate', listenerFunc: SpeechUpdateEventListener) => Promise<PluginListenerHandle>
ParamType
eventName'speechUpdate'
listenerFuncSpeechUpdateEventListener

Returns: Promise<PluginListenerHandle>


removeAllListeners()

removeAllListeners() => Promise<void>

Remove all listeners for this plugin.


Interfaces

IsMutedResult

PropType
mutedboolean

SayOptions

PropTypeDescription
messagestring
endCallAfterSpokenbooleanOnly available on Web.

SetMutedOptions

PropType
mutedboolean

SetupOptions

PropType
apiKeystring

StartOptions

PropType
assistantIdstring

PluginListenerHandle

PropType
remove() => Promise<void>

ConversationUpdateEvent

PropType
messages{ content: string; role: 'user' | 'assistant' | 'system'; }[]

ErrorEvent

Events providing information related to errors in scripts or in files.

PropType
colnonumber
errorany
filenamestring
linenonumber
messagestring

SpeechUpdateEvent

PropTypeDescription
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.