Squad support in web sdk
# support
h
Apologies but I want to integrate calling a squad into my FE app, is there a way to trigger with the web sdk or do I need to use the api directly?
a
Heyhealthmatch\_michael Thank you for creating the ticket! A member of our team will reach out to you shortly.
v
@healthmatch_michael Absolutely, you can integrate squad calling into your front-end application using the VAPI Web SDK. The SDK provides a convenient way to work with the Voice API directly from your front-end code, allowing you to trigger calls and manage squads without needing to interact with the API at the server level. To get started, you'll need to include the VAPI Web SDK in your project and initialize it with your credentials. Once that's done, you can create a squad and start a call by specifying the members, which can include both assistants and destinations. The first member in the list will be the assistant that initiates the call. If you need detailed instructions or code examples on how to implement this, please let me know, and I'll be happy to assist you further!
You can continue this conversation by mentioning me in the message.
h
give me examples @User
v
Got it. Tagging @User for additional help.
h
give me examples @Vapi
v
@healthmatch_michael Certainly! Here's a basic example of how you might use the VAPI Web SDK to trigger a squad call in your front-end application: 1. **Include the VAPI Web SDK**: First, you need to include the VAPI Web SDK in your project. This can typically be done by installing it via npm or including a script tag in your HTML if it's available as a CDN.
Copy code
html
<!-- Example of including VAPI Web SDK via CDN (URL is hypothetical) -->
<script src="https://cdn.vapi.com/sdk/vapi-web-sdk.min.js"></script>
2. **Initialize the SDK**: Before you can make any calls, you need to initialize the SDK with your credentials.
Copy code
javascript
const vapi = new VAPI({
    apiKey: 'your_api_key', // Replace with your actual API key
});
3. **Create a Squad and Trigger a Call**: Use the SDK to create a squad and start a call. You'll need to define the squad members and their roles.
Copy code
javascript
// Define squad members
const squadMembers = [
    { type: 'assistant', id: 'assistant_id' }, // The assistant that initiates the call
    { type: 'destination', number: '+1234567890' } // The destination phone number
];

// Start the call
vapi.squadCall(squadMembers)
    .then(response => {
        console.log('Call initiated successfully:', response);
    })
    .catch(error => {
        console.error('Error initiating call:', error);
    });
Please replace
'your_api_key'
,
'assistant_id'
, and
'+1234567890'
with your actual API key, assistant ID, and destination number, respectively. Remember, this is a simplified example to give you an idea of how to use the SDK. The actual implementation may vary based on the SDK's methods and the structure of your application. If you need more specific examples or have any questions about the code, feel free to ask!
h
does this definitely exist @Vapi
v
@healthmatch_michael Please ask support for more info on this.
s
@healthmatch_michael you have to pass the squadId as third parameter to the start function.
Copy code
ts
const call = vapi.start(null, null, <insert-here-squadId-or-squadConfig>)
h
perfect was just reading through the github now
ty
3 Views