Play audio.mp3 + let the Agent start the call
# support
p
Hey guys, I am using vapi to build an assistent functionality in my react-native app and want to do the following: Play a short audio file at the beginning of a call and then let the agent say something. More in detail: 1) Play a song for 10 seconds at the beginning of an initiated call. 2) Directly afterwards let the agents talk to the user and ask a question without the person needing to say something first. I was able to achieve both individually, but not in this sequence. If I add the audio in the "First Message" box then after it ends the agent is waiting for the person to say something. How can I implement this with the vapi api? Thank you very much for your help! Greetings from Bali
v
@PatrickWitzigmann Hello from VAPI support, and greetings to you in Bali! To achieve the sequence you're looking for, you can use the VAPI to control the flow of the call. Here's a general approach to how you can implement this: 1. Use the
call-start
event to trigger the audio playback at the beginning of the call. 2. After playing the audio file for 10 seconds, you can use a function to stop the playback. 3. Immediately after stopping the playback, you can trigger the agent's speech to ask the user a question. Since you've already managed to play the audio and let the agent speak individually, you just need to combine these actions in the right order. You might need to use a timer or a callback function to wait for the audio to finish before starting the agent's speech. If you need the exact code or functions to use within the VAPI, please provide the functions you have used so far to play the audio and to let the agent speak, and I can help you stitch them together in the correct sequence. If there's anything else you need assistance with, feel free to ask!
You can continue this conversation by mentioning me in the message.
p
I don't think it works that way?! Can you please help me @User @User?
s
You can use twilio flex whenever you get a call you can put it into the queue and then redirect the call to vapi assistant
p
@Sahil I want to implement this with the react-native SDK not over phone. Sorry I forgot to mention that. I was already trying to implement the audio playback individually, but your react-native SDK imlementation stops other audio streams in my app, so I wanted to try to build it directly in vapi.
s
You can play the mp3 audio in the first message mode
like you will need to add a mp3 link and it will work
p
This I am already doing. After the audio stopped however then the agent is waiting for the person to say something. I want the agent to say something first, as if I have the audio as First Message 1 and then the agent asking a question as First Message 2.
2 Views