How can I publish a DTMF from a function tool?
# ask-ai
p
How can I publish a DTMF from a function tool?
t
Thanks for reaching out, Mario. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
p
I'm using Python SDK
t
I'd be happy to help you publish DTMF (Dual-Tone Multi-Frequency) signals using the LiveKit Python SDK! You can use the
publish_dtmf
method on the
LocalParticipant
object. Here's a simple way to do it:
Copy code
await ctx.room.local_participant.publish_dtmf(
    code=1,  # Numeric DTMF signal code (e.g., 1 for digit '1')
    digit="1"  # String representation of the DTMF digit
)
For special characters like '*' and '#', you can use these codes: •
code=10
for '*' •
code=11
for '#' Here's an example for you:
Copy code
# Send '*'
await ctx.room.local_participant.publish_dtmf(code=10, digit="*")

# Send '#'
await ctx.room.local_participant.publish_dtmf(code=11, digit="#")
Also, it's a good idea to wrap this in a try-except block to gracefully catch any
PublishDTMFError
exceptions. If you run into any issues or have more questions, feel free to reach out—I'm here to help! Sources: Handling DTMF | LiveKit Docs | README.md | livekit-android-sdk/src/main/java/io/livekit/android/room/participant/Local... | livekit/src/room/participant/local_participant.rs | sip-refer/README.mdoc
p
how can I publish from
conversation_item_added
?
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!