<@U084APK40NS> I have the following function for t...
# ask-ai
c
@millions-hair-24956 I have the following function for the VoicePipelineAgent: @llm.ai_callable(description=“Called when the user wants the call to be forwarded to the operator”) async def forward_call( self, query: Annotated[ str, llm.TypeInfo(description=“User wants to forward the call to the operator”) ] Where does the voicepipelineagent and LLM look for the description? Is that in callableor in TypeInfo? What is the best practices for functions in this case
g
It seems likely that the
VoicePipelineAgent
and LLM use the
description
provided in the
@llm.ai_callable
decorator to understand when to invoke the function. The
description
in
llm.TypeInfo
is used to provide additional context about the function's parameters. This helps the LLM understand the purpose of each parameter when making function calls. For best practices, ensure that the
description
in
@llm.ai_callable
clearly states the function's purpose and when it should be called. The
description
in
llm.TypeInfo
should provide detailed information about each parameter, including its expected type and role in the function. This clarity helps the LLM make accurate decisions about when and how to use the function. Would you like more detail on how to structure these descriptions or examples of best practices? Sources: - Function calling with Voice Agents 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
c
@millions-hair-24956 If I want to transfer a call using this approach below, does this require sip outbout to be setup as well? transfer_request = TransferSIPParticipantRequest( participant_identity=self.participant.identity, room_name=self.ctx.room.name, transfer_to=phonenumber, play_dialtone=False ) logger.debug(_f_”Transfer request: {transfer_request}“) await self.lkapi.sip.transfer_sip_participant(transfer_request)
g
Yes, transferring a call using the
TransferSIPParticipantRequest
requires that an outbound SIP trunk is set up. This is because the transfer involves making an outbound call to the specified phone number (
transfer_to
), which necessitates an outbound trunk configuration to handle the SIP traffic. Would you like more details on setting up an outbound SIP trunk or the transfer process? Sources: - Transferring calls - SIP outbound trunk setup 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
c
@millions-hair-24956 when creating an Inbound trunk I get a Siptrunk ID, when creating an outbound trunk I get a siptrunk ID. Do both siptrunk ID”s need to be added to the dispatch-rule.json, like below or just the inbound id? { “name”: “LiveKit Telynx Call Agent Dispatch Rule”, “trunk_ids”: [“adfsgasgagasdg”], “rule”: { “dispatchRuleIndividual”: { “roomPrefix”: “call-room-“, “pin”: “” } } }
g
It might be that only the inbound SIP trunk ID needs to be added to the
dispatch-rule.json
. The dispatch rule is primarily used to route incoming calls to specific rooms, so it typically references the inbound trunk ID. The outbound trunk ID is generally not required in the dispatch rule, as it is used for making outgoing calls rather than handling incoming ones. Would you like more information on configuring dispatch rules or the role of SIP trunk IDs? Sources: - https://docs.livekit.io/sip/quickstart/ - https://docs.livekit.io/sip/quickstarts/accepting-calls/ Note: I wasn’t able to find highly relevant data sources, but above are a few potentially relevant links. 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
c
@millions-hair-24956 below is my code for transfersipparticipant:
Copy code
@llm.ai_callable(description="Called when the user wants the call to be forwarded to the operator")
    async def forward_call(
        self,
        query: Annotated[
            str,
            llm.TypeInfo(description="User wants to forward the call to the operator")
        ]
    ):

        print(f"-----------Forwarding call to {query}")

        if self.phone_number == "848484":
            
            transfer_request = TransferSIPParticipantRequest(
                participant_identity=self.participant.identity,
                room_name=self.ctx.room.name,
                transfer_to="++3185849492",
                play_dialtone=False
                )
            
            logger.debug(f"Transfer request: {transfer_request}")
            
            try:
                await self.lkapi.sip.transfer_sip_participant(transfer_request)
            except Exception as e:
                logger.error(f"Transfer failed: {e}")
This however, doesn’t seem to work, while the outbound trunk is setup with Telnyx. What might be going wrong here?
g
It seems likely that the issue could be related to several factors, such as the configuration of the outbound trunk, the SIP transfer setup, or the handling of the transfer request. Here are a few areas to check: 1. Outbound Trunk Configuration: Ensure that your outbound trunk with Telnyx is correctly configured and that it allows for call transfers. Verify that the trunk is active and that the credentials (username and password) are correct. 2. TransferSIPParticipantRequest Parameters: Double-check the parameters in your
TransferSIPParticipantRequest
. Ensure that the
participant_identity
and
room_name
are correct and that the
transfer_to
number is in the correct format (e.g., E.164 format). 3. Error Handling: The error message logged in the exception block might provide more insight into what is going wrong. Ensure that the logger is correctly set up to capture and display these error messages. 4. Telnyx Configuration: Confirm with Telnyx support that your account is set up to handle SIP REFER transfers and that there are no restrictions or additional settings required on their end. Would you like more detailed guidance on any of these points? Sources: - Transferring calls 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
c
@millions-hair-24956 I keep getting this error with the code below
Copy code
@llm.ai_callable(description="Called when the user wants the call to be forwarded to the operator")
    async def forward_call(
        self,
        query: Annotated[
            str,
            llm.TypeInfo(description="User wants to forward the call to the operator")
        ]
    ):

        print(f"-----------Forwarding call to {query}")

        if self.phone_number == "848484":
            
            transfer_request = TransferSIPParticipantRequest(
                participant_identity=self.participant.identity,
                room_name=self.ctx.room.name,
                transfer_to="++3185849492",
                play_dialtone=False
                )
            
            logger.debug(f"Transfer request: {transfer_request}")
            
            try:
                await self.lkapi.sip.transfer_sip_participant(transfer_request)
            except Exception as e:
                logger.error(f"Transfer failed: {e}")
voice-agent-callable-functions - Transfer failed: (‘deadline_exceeded’, ‘request timed out’) Also it looks like my outbound-trunk is setup correctly: { “trunk”: { “name”: “Outbound Telnyx LiveKit Call Agent Trunk”, “address”: “sip.telnyx.com”, “numbers”: [“+3242424124”], “auth_username”: “asdgasdgadga”, “auth_password”: “asdgagasgdasdg” } } What might I be missing here, because standard outbound call does work when I test it with “lk sip participant create sipParticipant.json”
g
It seems likely that the "deadline_exceeded" error indicates a timeout issue, which could be due to several factors. Here are some potential areas to investigate: 1. Network Latency: Check for any network latency or connectivity issues between your LiveKit server and the Telnyx SIP server. Ensure that your network is stable and that there are no firewalls or security settings blocking the connection. 2. SIP Trunk Configuration: Verify that your SIP trunk configuration is correct and that the credentials (username and password) are valid. Ensure that the trunk is set up to handle SIP REFER transfers, as this is required for call transfers. 3. Transfer Request Parameters: Double-check the parameters in your
TransferSIPParticipantRequest
. Ensure that the
participant_identity
,
room_name
, and
transfer_to
fields are correctly specified. The
transfer_to
number should be in the correct format (e.g., E.164 format). 4. Timeout Settings: If possible, adjust the timeout settings for the transfer request to allow more time for the operation to complete. This might involve modifying the configuration on the LiveKit or Telnyx side. 5. Telnyx Support: Contact Telnyx support to ensure that your account is configured to handle SIP REFER transfers and that there are no restrictions or additional settings required on their end. Would you like more detailed guidance on any of these points? Sources: - Transferring calls 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
c
@millions-hair-24956 can it be that the phone number provider: Telnyx in this case, needs to enable PTSN Transfer and/or SIP Transfer in order for TransferSIPParticipantRequest to work?
g
Yes, it is possible that Telnyx needs to enable PSTN (Public Switched Telephone Network) transfers and/or SIP transfers for the
TransferSIPParticipantRequest
to work. According to a Slack conversation, enabling PSTN transfers is necessary for certain SIP trunk configurations to support call transfers. Would you like more details on how to proceed with enabling these features or any other related information? Sources: - Slack conversation on SIP transfer with Telnyx 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.