<@U084APK40NS> Telnyx SIP Refer how?
# ask-ai
a
@millions-hair-24956 Telnyx SIP Refer how?
g
To perform a SIP REFER (cold transfer) using Telnyx with LiveKit, you need to use the
TransferSIPParticipant
API. This API allows you to transfer a SIP participant to another phone number or SIP endpoint. Ensure your Telnyx SIP trunk is configured to allow call transfers. The
transferTo
parameter can be a valid telephone number or a SIP URI, such as
tel:+15105550100
or
sip:+15105550100@sip.telnyx.com
source. Would you like more details on setting up the SIP trunk or using the API? Sources: - https://docs.livekit.io/sip/transfer-cold/ 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
a
@millions-hair-24956 when I do a SIP refer, I keep getting a deadline exceeded I am using TransferSIPParticipantRequest and Telnyx
g
It seems likely that the "deadline exceeded" error during a SIP REFER using
TransferSIPParticipantRequest
with Telnyx could be related to network latency or configuration issues. My understanding is that you should ensure that your Telnyx SIP trunk is properly configured to handle call transfers and that the network connection is stable. Additionally, verify that the
transferTo
parameter is correctly formatted and that the Telnyx account settings allow for PSTN transfers source. Would you like more detailed troubleshooting steps or configuration guidance? Sources: - https://docs.livekit.io/sip/transfer-cold/ 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
a
@millions-hair-24956 How do I know the Telnyx SIP can handle call transfers?
g
To ensure that your Telnyx SIP trunk can handle call transfers, you need to verify a few configurations: 1. Enable Call Transfers: Confirm with Telnyx support that your SIP trunk is configured to allow call transfers, specifically SIP REFER. This might require enabling specific features or settings on your Telnyx account. 2. Check Trunk Configuration: Ensure that your SIP trunk is set up correctly with the necessary permissions for call transfers. This includes verifying that the
transferTo
parameter is correctly formatted as a valid telephone number or SIP URI, such as
tel:+15105550100
or
sip:+15105550100@sip.telnyx.com
source. 3. Network and Permissions: Make sure that your network settings and permissions are configured to support SIP REFER messages. This includes checking firewall settings and ensuring that the necessary ports are open. Would you like more detailed steps on configuring your Telnyx SIP trunk? Sources: - https://docs.livekit.io/sip/transfer-cold/ 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
a
@millions-hair-24956 How can I tell if the Telnyx account allows it?
g
To determine if your Telnyx account allows call transfers, you should: 1. Contact Telnyx Support: Reach out to Telnyx support to confirm that your account and SIP trunk are configured to support call transfers, specifically SIP REFER. They can provide details on whether PSTN transfers are enabled for your trunk. 2. Check Account Settings: Log into your Telnyx account and review the settings for your SIP trunk. Look for any options related to call transfers or SIP REFER and ensure they are enabled. 3. Review Documentation: Consult Telnyx's documentation or configuration guides to verify that your account settings align with the requirements for enabling call transfers. Would you like more information on configuring your Telnyx account for call transfers? Sources: - https://livekit-users.slack.com/archives/C07FRP66XGE/p1733811243.825129 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
a
@millions-hair-24956 how do I get a a voice pipeline to say a specific line?
g
To make a VoicePipelineAgent say a specific line, you can use the
say
method. This method allows you to play a speech source through the voice assistant. You can pass a string directly to the
say
method to have the agent speak that line. Here's a basic example:
Copy code
from livekit.agents.pipeline import VoicePipelineAgent

# Assuming 'agent' is an instance of VoicePipelineAgent
await agent.say("Hello, this is a specific line.")
Would you like more details on using the
say
method or setting up the VoicePipelineAgent? Sources: - https://docs.livekit.io/python/livekit/agents/pipeline/index.html#livekit.agents.pipeline.VoicePipelineAgent.MIN_TIME_PLAYED_FOR_COMMIT - https://docs.livekit.io/agents-js/classes/agents.pipeline.VoicePipelineAgent.html 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
a
@millions-hair-24956 I have a tool call, where I want the agent to say a specific line, how do you recommend going that?
g
To have the agent say a specific line during a tool call, you can use the
say
method of the
VoicePipelineAgent
before or after executing the tool call. This approach ensures that the agent speaks the desired line at the appropriate time in the workflow. Here's a basic example:
Copy code
from livekit.agents.pipeline import VoicePipelineAgent

# Assuming 'agent' is an instance of VoicePipelineAgent
async def tool_call():
    # Say a specific line before the tool call
    await agent.say("Let me check that for you.")
    
    # Execute the tool call
    # ... (tool call logic here)

    # Optionally, say another line after the tool call
    await agent.say("The tool call is complete.")
Would you like more detailed guidance on integrating this with your specific tool call setup? Sources: - https://docs.livekit.io/python/livekit/agents/pipeline/index.html#livekit.agents.pipeline.VoicePipelineAgent.MIN_TIME_PLAYED_FOR_COMMIT - https://docs.livekit.io/agents-js/classes/agents.pipeline.VoicePipelineAgent.html 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
a
@millions-hair-24956 but how do I pass the agent to the tool call?
g
To pass the
VoicePipelineAgent
instance to a tool call, you can include it as a parameter in the function definition of the tool call. This allows you to use the agent's methods, such as
say
, within the tool call. Here's an example:
Copy code
from livekit.agents.pipeline import VoicePipelineAgent

# Define your tool call function
async def tool_call(agent: VoicePipelineAgent):
    # Use the agent to say a specific line
    await agent.say("Let me check that for you.")
    
    # Execute the tool call logic
    # ... (tool call logic here)

    # Optionally, say another line after the tool call
    await agent.say("The tool call is complete.")

# Assuming 'agent' is an instance of VoicePipelineAgent
# Call the tool call function with the agent
await tool_call(agent)
Would you like more detailed guidance on integrating this with your specific setup? Sources: - https://docs.livekit.io/agents/voice-agent/function-calling/ - https://livekit-users.slack.com/archives/C07FY8WHGPM/p1728124961.554009 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
a
@millions-hair-24956 but how do I pass in the agent in the following code
Copy code
agent = VoicePipelineAgent(
        vad=ctx.proc.userdata["vad"],
        stt=deepgram.STT(model="nova-2-general"),
        llm=openai.LLM(model="gpt-4o-mini"),
        tts=cartesia.TTS(),
        chat_ctx=initial_ctx,
        fnc_ctx=CallActions(api=ctx.api, participant=participant, room=ctx.room),
    )
the tools are passed to the initialization of the agent, so I don't have access
g
It seems likely that you can pass the
VoicePipelineAgent
instance to the tools by including it in the
fnc_ctx
(function context) during the initialization of the agent. You can modify the
CallActions
class to accept the agent as a parameter. Here's an example of how you might do this: 1. Modify the
CallActions
class
to accept an agent parameter:
Copy code
class CallActions:
    def __init__(self, api, participant, room, agent):
        self.api = api
        self.participant = participant
        self.room = room
        self.agent = agent

    # Example method using the agent
    async def some_tool_call(self):
        await self.agent.say("Executing tool call.")
        # Tool call logic here
2. Initialize the
VoicePipelineAgent
and pass the agent to `CallActions`:
Copy code
agent = VoicePipelineAgent(
    vad=ctx.proc.userdata["vad"],
    stt=deepgram.STT(model="nova-2-general"),
    llm=openai.LLM(model="gpt-4o-mini"),
    tts=cartesia.TTS(),
    chat_ctx=initial_ctx,
    fnc_ctx=CallActions(api=ctx.api, participant=participant, room=ctx.room, agent=None),  # Temporarily set agent to None
)

# Now that the agent is created, set it in the CallActions
agent.fnc_ctx.agent = agent
This approach allows you to use the
agent
within your tool calls by accessing it through the
fnc_ctx
. Would you like more detailed guidance on this approach? Sources: - https://docs.livekit.io/agents/voice-agent/function-calling/ 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.