Hello Team, I am able to get inbound calls workin...
# telephony
w
Hello Team, I am able to get inbound calls working fine whenever I call the number associated with my trunk, however when I am setting up my outbound calling and trying to initiate an outbound call, I get a 403 Forbidden Error. Is this an issue caused by Livekit with something to do with permissions or is it something I need to change on the Twilio side? Any help on this would be greatly appreciated. Thanks!
r
Did you see you Twilio credentials in the trunk config?
w
Thank you for the response! I was able to somehow get the outbound call working, I think when I specified the specific trunk number to call from. However, whenever I add the outbound call functionality in the entrypoint function, before agent session is initiated, the call does not go out. Would you know if I’m doing something wrong or I’m not fundamentally understanding how the outbound call process with the agents work?
r
What is the trunk ID you are having an issue with? it will start with
ST_
w
ST_5XXbaeg2EwCT, this is the current outbound trunk I am using. Could you also tell me if I am understanding the entire workflow process correctly, which may possibly be leading to my misunderstanding of the whole outbound call process. We have to initiate an outbound call using the SIP_particpant_request and call through the api module in python. This will then initiate an outbound call and create a room with the SIP participant. Then whenever there is a participant in the room, then the agent is dispatched to the room for the job. Then on the phone, the agent can be heard and can communicate. However, where I am getting confused and it is not working unless I do it separately, is that the entry point function will only run whenever the agent has been dispatched to the room for the job, and if this is the case, then if the outbound call initiation takes place in the entrypoint function, then it won't be able to make the call out since it has not been executed yet as the agent job has not yet been dispatched. If you could tell me if I am understanding the process incorrectly, or am missing out on something which is causing me to run into issues it would be great! Thanks
r
w
Thank you. I implemented my own version and with trying to understanding the meaning of the code. If you could let me know if I get it down or not, the code with the agent class and entrypoint would be running continuously (in a production environment) and whenever we would need to make an outbound call, we would just dispatch the agent by running the other file, which ends up having the entrypoint function run and the call is initiated?
Also, I get the call but it seems that the agent starts talking and publishing tracks even before the call is picked up since if I let it ring more, and then pick it up, the agent is halfway in its introduction. Would you know how to mitigate this issue?
r
That all sounds wrong to me
The proper sequence is demonstrated in the survey caller example 1. Agent dispatch is created first - This tells LiveKit to prepare an agent for the room 2. SIP participant is created second - This initiates the actual phone call 3. Agent entrypoint runs when the room becomes active - The agent connects and starts processing
The issue you're experiencing where the agent starts talking before the call is picked up is related to SIP call status tracking. sip_lifecycle.py:184-194 The agent should wait for the call status to be "_active_" before starting to speak. You can monitor SIP call status changes using participant attributes: sip_lifecycle.py:197-218
w
This is great and thank you for your help! What I meant when I said the entrypoint is running continuously is that, the agent code when it registers as a worker with the livekit server, it will always run so that it can dispatch an agent whenever it is prompted to, but not sure if this may also not be a proper understanding
r
a worker is running. When it get a job (dispatch) it will spawn a process where entrypoint ( your agent code) gets run
w
Great! Thank you for help. Also, would you know why I have to always run the download-files command, before I can run it in dev mode? If I dont do it this way, I get an _ipc error
r
You should only need to run it once. It uses the hugging face library to download the model. After you run download files do you see the turn detector here?
~/.cache/huggingface/hub/
? Is it possible something is wiping that directory out between runs?
w
Im not sure, I don't see anything like that. I am using PyCharm so that may be the case, I'll test it out with VS code to see if it persists. Thank you for your assitance, it has been very useful