Using Asterisk TALK_DETECT to trigger Python Script via AGI

Hi there,

I am new to the Asterisk AGI and I am trying to use a extension_custom destination as a python script to answer calls and based on when asterisk detects Talking or Silence perform an action.

I have configured the destination with TALK_DETECT and via the asterisk CLI I can see these events however I am not sure how to pass these via the AGI to the script to trigger the events.

PJSIP/opanei1-00000033 is now talking
PJSIP/opanei1-00000033 is now silent
PJSIP/opanei1-00000033 is now talking
PJSIP/opanei1-00000033 is now silent

Is there any documentation or reference code people have come across with a similar requirement?

You can’t. AGI isn’t an event based mechanism, it doesn’t receive those events or such information. They go out over AMI or ARI, so the AGI instead would have to connect to AMI to get them.

I thought this may be the case so was already looking into the AMI. From the Asterisk CLI logs with Manager debugging enabled I can see the ChannelTalkingStart & ChannelTalkingStop events listed however I am not able to see them being passed to the script via the AMI interface.

I am only seeing events like:

2024-06-18 03:28:33,472 - INFO - Received AMI event: Event : RTCPSent → {‘Privilege’: ‘reporting,all’, ‘Channel’: ‘PJSIP/opanei1-00000003’, ‘ChannelState’: ‘6’, ‘ChannelStateDesc’: ‘Up’, ‘CallerIDNum’: ‘opanei1’, ‘CallerIDName’: ‘opanei1’, ‘ConnectedLineNum’: ‘’, ‘ConnectedLineName’: ‘’, ‘Language’: ‘en’, ‘AccountCode’: ‘’, ‘Context’: ‘ai-agent-cameron’, ‘Exten’: ‘s’, ‘Priority’: ‘4’, ‘Uniqueid’: ‘1718681298.6’, ‘Linkedid’: ‘1718681298.6’, ‘To’: ‘45.79.X.X:12115’, ‘From’: ‘172.105.X.X:19585’, ‘MES’: ‘85.4’, ‘SSRC’: ‘0x2b50566c’, ‘PT’: ‘200(SR)’, ‘ReportCount’: ‘1’, ‘SentNTP’: ‘1718681313.466377’, ‘SentRTP’: ‘89834’, ‘SentPackets’: ‘562’, ‘SentOctets’: ‘89834’, ‘Report0SourceSSRC’: ‘0x2719639e’, ‘Report0FractionLost’: ‘0’, ‘Report0CumulativeLost’: ‘0’, ‘Report0HighestSequence’: ‘19928’, ‘Report0SequenceNumberCycles’: ‘0’, ‘Report0IAJitter’: ‘1’, ‘Report0LSR’: ‘0’, ‘Report0DLSR’: ‘0.0000’}

Does anyone have experience in this field who may be able to assist in the coding?

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