Is there a way to send information to a running as...
# support
k
Personal Assistant Use case: User asks for some research which takes longer than 20 seconds. Research is done async and then i would like to tell the assistant the result once it is ready (e.g. 2 minutes later). 2 questions: - Can i use vapi.send from the SDK for this? (so does the assistant react to the text messages i sent?) - Is there a way to do this via API? Because I would like to have my Backend call the VAPI Api with the results of the research. Thanks!
v
Hi @kwkrass, I'm an AI assistant for Vapi. I'll analyze available sources and get back to you shortly.
----------------------------- **While I generate an answer, here are some sources that might be helpful**: * [Create Assistant]() * [Get Assistant]() * [Server Events]() * [Web SDK]() -----------------------------
### Answer For your use case, using the
.send()
method from the SDK can be a way to interact with your assistant dynamically. Specifically, you can use this method to send text messages to the assistant during a session, including results from asynchronous operations that your backend might perform. The assistant will react to these messages as part of the conversation. This approach is documented in the Vapi Web SDK, where you can send intermediate messages to the assistant, such as updating the chat with the results of your research when ready [(1)]() [(2)]() . However, to directly send information from your backend to a running assistant via an API, the detailed documentation does not explicitly outline a direct API endpoint for injecting messages into an active assistant session. The primary interactions with assistants through the API involve creating, updating, getting, and deleting assistants [(3)]() [(4)]() [(5)]() [(6)]() . For backend-to-assistant communication reflecting the results of asynchronous research or tasks, you might consider utilizing webhook events or server URL configurations where your server can respond to requests from the assistant for updated information or function calls during a conversation. This mechanism supports asynchronous operations where the assistant can request information, and your server provides responses when the data is ready [(7)]() . In summary, while
.send()
in the SDK can be used for updating an ongoing session with new messages from the client-s
ide [(1)]() [(2)]() , direct backend-to-assistant communication for asynchronous tasks might rely on configuring your assistant's interactions with your server via server URL settings or function calls for dynamic content delivery during the conversation [(7)]() .
Got it. Tagging @User for additional help.
k
First: I am really impressed with these AI generated answers! Somehow they are better than the AI answers from the documentation i feel 🙂 Still i would have the question: What's the recommended option in my use case? Is the API message sending planned to be added at some point?
s
Through Custom Function you can get the data in real-time
k
yes but how does the AI assistant know when the research is ready and when it should ask for the data?
(since the research being done after my function calling takes longer than 20 seconds)
s
It will need to take that much time. You can either reduce the function calling time or anything else
like maybe add in the prompt before function calling say this wait for 30secs or something else
k
ok thanks - good idea as a workaround. still eventually it would be good to be able to control the function calling time and be able to send messages to the assistant via API ... #featurewish
s
thanks!