Using ARI to send DTMF

Hi, I’ve got an FXO analogue line card hooked up to Asterisk with DAHDI drivers and want to try and automate going off-hook and dialling a number so simulate a user using an analogue phone.

I’m using the Python language binding for ARI and have created the channel-dump Stasis application running in the background. So far I have:

channel = client.channels.create(endpoint='DAHDI/16', app='channel-dump')
channel.dial()
channel.sendDTMF(dtmf='1234')

However the sendDTMF function returns with the error:

412 Client Error: Precondition Failed for url: http://asterisk:8088/ari/channels/1591883354.12/dtmf?dtmf=1234

Is there more initialisation I need to do in order to send DTMF?

What’s the status of the channel? Is it answered? If you use the new originate does it work? Is there a reason you don’t put the DTMF into the endpoint string?

Have just tested with originate instead

channel = client.channels.originate(endpoint='DAHDI/16', app='channel-dump')

then

channel.sendDTMF(dtmf="1234")

This actually works!
Was not aware you could add DTMF to the end of the endpoint string, but that works too.

I’m not really clear on the difference between channels.create and channels.originate which led to my confusion.

I’d like to be able to extend this example to know when extension 1234 has been answered. My stasis app is printing out events StasisStart StasisEnd and ChannelStateChange however I’m not seeing any event created when 1234 is answered. Is there an event I’m missing or lack of understanding on my part here?

Originate does not send a channel into the Stasis application until it is answered. Create and dial sends the channel into the Stasis application before it is answered, but it expects to be put into a bridge with another channel. I don’t recall the specific events, but upon entering the Stasis application it is answered. If an analog line though they are generally immediately answered.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.