passing data from the client before the call stars
# support
a
Hi, I am new to Vapi API and I am using the web SDK with next js, But I am unable to pass data from the client side before the call begins
Copy code
await vapi.start('2xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', {
                metadata: interviewInfo,
                onSpeech: (data) => {
                    console.log('Transcript:', data.text); 
                },
            });
also I am trying to console log the transcript but both are not working for me. I would appreciate any help please.
v
@abmoallim Hello and welcome to VAPI! I'm glad to assist you with your integration into Next.js. Firstly, ensure that you have correctly installed the VAPI package and imported it into your Next.js project as shown in the installation instructions. For passing metadata before the call begins, you should ensure that
interviewInfo
is a properly formatted object that contains the data you want to pass. Here's an example of how you might structure it:
Copy code
javascript
const interviewInfo = {
  candidateName: "John Doe",
  position: "Software Developer"
};
Regarding the
start
method, it looks like you're using it correctly. However, make sure that the
2xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
is replaced with a valid call token that you have obtained from your backend service. For the
onSpeech
callback, it should work as intended if the call is set up correctly. If you're not seeing any console logs, there might be an issue with the call setup or the speech recognition service. Here's a checklist to troubleshoot the issue: 1. Verify that you have a valid Public Key and that you've initialized the
Vapi
instance with it. 2. Ensure that the call token you're using is valid and has not expired. 3. Check your browser's console for any errors that might indicate what's going wrong. 4. Make sure that your browser has permission to use the microphone, as this is necessary for the
onSpeech
event to work. 5. If you're developing locally, ensure that you're serving your Next.js app over HTTPS, as modern browsers require a secure context for microphone access. If you've gone through these steps and are still facing issues, please provide any error messages or additional context that might help in diagnosing the problem. If you need further assistance, don't hesitate to ask for more information.
You can continue this conversation by mentioning me in the message.
a
@Vapi I have a valid Public Key and a valid call token the call is working fine, and I have the interviewInfo object it's just the information that is not been passed and the transcript no showing
v
@abmoallim Great to hear that you have a valid Public Key and call token, and that the call is working fine. Let's address the two issues you're facing: 1. Metadata not being passed: - Ensure that the
metadata
property is supported by the VAPI SDK you are using. The property name might differ, or the feature might need to be enabled in a different way. - Double-check that the
interviewInfo
object is correctly formatted and contains the data you expect to pass. It should be a plain object with key-value pairs. 2. Transcript not showing: - The
onSpeech
callback should be triggered whenever speech is detected and transcribed. If it's not being called, it could be due to the speech not being recognized or an issue with the event hook-up. - Verify that the microphone is capturing audio clearly and that there is no issue with the audio input. - Check if there are any errors in the browser console that could indicate why the
onSpeech
event is not firing. - Ensure that the SDK version you are using supports the
onSpeech
callback and that you are using it as per the documentation. If you've verified all of the above and the issues persist, it might be helpful to look at the network requests in your browser's developer tools to see if the metadata is being sent and if there are any responses related to speech recognition. If you're still unable to resolve the issue, please provide any error messages or console logs you're seeing, as they can offer more clues about what might be going wrong. If necessary, you can reach out to VAPI support for more detailed assistance with your specific implementation.
s
@abmoallim hey if your trying to send personalizaed data to the assistant you have to subscribe to server events. check this doc: https://docs.vapi.ai/server-url/events#retrieving-assistants
a
@Shubham Bajaj thank you so much, but I found out that the vapi.start( ) can take two types of parameter 1) A string ( assistantID) 2) object ( assistant info and prompt) In option 2 I can pass the information I want
s
9 Views