https://retellai.com/?utm_source=discord&utm_medium=seo logo
Function calling on client app
# ❓・bug-report
c
It looks like custom tools require a URL parameter. I was wondering if instead of pinging an external URL, I can get the function call details sent directly to my client app using WebSockets? i.e. I’m imagining something similar to
wss://.../audio-websocket/...?enable_update=true
. But instead of
"event_type": "update"
, maybe
"event_type": "tool_call", "name": "xyz", "args": "…"
? (And probably separate from
?enable_update
, since the output for that is quite long and difficult to parse on low-powered devices, and I would just discard all the
update
messages anyway. Something like
?enable_update=true&filter=tool_call
would be neat.)
n
The custom tools are configured with retell LLM and the LLM takes decision to call them and then Retell would have written some logic on their server side to execute the function. So I don't think that the structure of custom tools can change here. Also passing it in the websocket, how will it allow Retell to execute your function hosted on some server?
c
One good example might be: ‘Hey Retell, turn the volume down.’ In that case, I would really like to have Retell notify my application that the user has called
volume_down
.
I was thinking I could just call
https://example.com/always-succeeds
and then as long as I get a log with
?enable_update
that the function has been called, I can handle it on the client side.
I mean, ideally I can just leave URL blank and Retell just assumes there’s no need to wait for a response, but I understand you probably don’t want to write special case logic for just my use case.
z
Hey Chris, looking at these messages, I think what you were looking for is actually being able to see the function invocation in frontend. This is however, a bit insecure, because if you allow that in frontend, then others might be able to see internal api keys, api results etc that only should exist in backend.
Thus I wonder if it's possible for you to set up something in the backend and ping your frontend once you receive the function invocation request
c
Thanks so much, Zexia. Right, that's exactly right! I hadn't thought about the security aspects of broadly logging all function calls; that's a good point... Could there eventually be a second kind of function calling in the future that is directed to the client – even if it's only one-way and doesn't wait for a response? The current workaround would be to spin up another server, open a second WebSocket to the client, receive the POST requests, then relay those to the client. It's doable but I feel like something we'd want to optimize in the future, to get rid of that extra unnecessary POST and make it a bit less fragile with the dual WebSockets.
Perhaps an 'Advanced: Notify client of invocation (insecure)' checkbox for each tool would be neat, (or some hidden setting if having it in the UI is overkill).
z
got it, we will keep that in mind for sure!