Detect only single button press

Hello. In my IVR, It recognized double DTMF values. I need to keep only one DTMF value. ( I mean, If user press 1 and 3 in same time, My asterisk recognize it as 13. But I need to get only one value, If user press 1 and 3 in same time, I need to get only 1st presses number.) How do it

You would need to show the dialplan and console output, to show exactly what you are doing and how you are using Asterisk.

As far as anything at the other end of the line from the phone is concerned, those are two consecutive key presses. If you are using WaitExten or Background, you are going to have to train your users better. If you are using Read, you will need to limit the number of digits you process.

Note that it is likely that the phone scans the key board, so if certain combinations of keys are pressed sufficiently close together, they may be read in a different order, than pressed, by the phone. This means that even if you could disable key rollover on the phone, it might still produce unexpected results. Key rollover is to the ability to press a sequence of keys with down times for the keys overlapping, and still have them interpreted as a sequence. (Keyboards without rollover support are rare, and tend to return a completely wrong key-press when this happens. Standard computer keyboards have rollover.)

This is my extensions.conf code

[from_external]
exten => _01120195XX,1,NoOp(Incoming call from ${EXTEN})
   same => n,Set(DIALED_NUMBER=${EXTEN})
   same => n,Goto(dmse_IVR,s,1)


[dmse_IVR]
exten => s,1,Answer()
   same => n,Set(FILENAME=/path/to/call_log.txt)
   same => n,Set(CALL_DETAILS=${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M:%S)} - Caller ID: ${CALLERID(num)}, Button Pressed: 2, Unique ID:${CONFID})
   same => n,System(echo "${CALL_DETAILS}" >> ${FILENAME})
   same => n,Set(TEST_MESSAGE=Testing logging)
   same => n,System(echo "${TEST_MESSAGE}" >> ${FILENAME})

; Use DIALED_NUMBER directly to set DESTINATION_NUMBER
   same => n,Set(DESTINATION_NUMBER=${DIALED_NUMBER})

   same => n,Set(CDR(userfield)=${DIALED_NUMBER}) ; Optional: Set custom CDR userfield
   same => n,Set(CDR(destination_number)=${STRFTIME(${EPOCH},,%Y%m%d%H%M%S)}${CALLERID(num)})

   ; Insert call details into the database including the destination number
   same => n,Set(ODBC_WRITE('${CDR(calldate)}', '${CDR(clid)}', '${CDR(src)}', '${CDR(dst)}', '${CDR(destination_number)}', '${CDR(dcontext)}', '${CDR(channel)}', '${CDR(dstchannel)}', '${CDR(lastapp)}', '${CDR(lastdata)}', ${CDR(durati>

   same => n,Set(tries=0)
   same => n,Goto(testing,s,1)


[welcomeloop]
   ; play welcome dms message for Language Selection
   exten => s,1,NoOp(Incoming call to 'welcomeloop')
   same => n,Background(welcomedmse)

   ; Check for DTMF while playing the prompt
   ;same => n,Set(user_inputs=${CHANNEL(dtmf)})

   ; If '1' is pressed, stop the playback and go to English_lang
   ;same => n,GotoIf($["${user_inputs}" = "1"]?English_lang,s,1)

   ; If '2' is pressed, stop the playback and go to Sinhala_lang
   ;same => n,GotoIf($["${user_inputs}" = "2"]?Sinhala_lang,s,1)

   ; If '3' is pressed, stop the playback and go to Tamil_lang
   ;same => n,GotoIf($["${user_inputs}" = "3"]?Tamil_lang,s,1)

   same => n,Read(user_inputs)

   ; User Inputs
   same => n,WaitExten(2)
   same => n,GotoIf($["${user_inputs}" = "1"]?English_lang,s,1)
   same => n,GotoIf($["${user_inputs}" = "2"]?Sinhala_lang,s,1)
   same => n,GotoIf($["${user_inputs}" = "3"]?Tamil_lang,s,1)
   same => n,Playback(wrongInput)
   same => n,WaitExten(2)
   same => n,Set(tries=$[${tries} +1])

   ; Check user input 3 wrong inputs
   same => n,GotoIf($[${tries}>=3]?Hangup)

   ; If user enters wrong input, Play welcomedmse voice again
   same => n,Goto(welcomeloop,s,1)

   ; Handle unexpected input
   same => n,Playback(wrongInput)
   same => n,WaitExten(2)
   same => n,Goto(welcomeloop,s,1)

[English_lang]
   ; If user presses 1, go to English Language
   exten => s,1,NoOp(User Pressed 1 and go to English path)
   same => n,Playback(dmsevoice)
   same => n,Hangup()

[Sinhala_lang]
   ; If user presses 2, go to Sinhala Language
   exten => s,1,NoOp(User Pressed 2 and go to Sinhala path)
   same => n,Playback(dmsevoice)
   same => n,Hangup()



This is CLI when customer make the call

Connected to Asterisk 18.10.0~dfsg+~cs6.10.40431411-2 currently running on dms (pid = 3937)
    -- Executing [011201xxxx@from_external:1] NoOp("PJSIP/registrar-00000001", "Incoming call from 011201xxxx") in new stack
    -- Executing [011201xxxx@from_external:2] Set("PJSIP/registrar-00000001", "DIALED_NUMBER=011201xxxx") in new stack
    -- Executing [011201xxxx@from_external:3] Goto("PJSIP/registrar-00000001", "dmse_IVR,s,1") in new stack
    -- Goto (dmse_IVR,s,1)
    -- Executing [s@dmse_IVR:1] Answer("PJSIP/registrar-00000001", "") in new stack
       > 0x7f28a401b5a0 -- Strict RTP learning after remote address set to: 172.20.xx.xx:6030
    -- Executing [s@dmse_IVR:2] Set("PJSIP/registrar-00000001", "FILENAME=/path/to/call_log.txt") in new stack
    -- Executing [s@dmse_IVR:3] Set("PJSIP/registrar-00000001", "CALL_DETAILS=2024-03-19 09:48:56 - Caller ID: 07538xxxxx, Button Pressed: 2, Unique ID:") in new stack
    -- Executing [s@dmse_IVR:4] System("PJSIP/registrar-00000001", "echo "2024-03-19 09:48:56 - Caller ID: 0753xxxxx, Button Pressed: 2, Unique ID:" >> /path/to/call_log.txt") in new stack
       > 0x7f28a401b5a0 -- Strict RTP switching to RTP target address 172.20.xx.xx:6030 as source
    -- Executing [s@dmse_IVR:5] Set("PJSIP/registrar-00000001", "TEST_MESSAGE=Testing logging") in new stack
    -- Executing [s@dmse_IVR:6] System("PJSIP/registrar-00000001", "echo "Testing logging" >> /path/to/call_log.txt") in new stack
    -- Executing [s@dmse_IVR:7] Set("PJSIP/registrar-00000001", "DESTINATION_NUMBER=011201xxxx") in new stack
    -- Executing [s@dmse_IVR:8] Set("PJSIP/registrar-00000001", "CDR(userfield)=011201xxxx") in new stack
    -- Executing [s@dmse_IVR:9] Set("PJSIP/registrar-00000001", "CDR(destination_number)=202403190948560753xxxxxx") in new stack
    -- Executing [s@dmse_IVR:10] Set("PJSIP/registrar-00000001", "ODBC_WRITE('', '"0753xxxxx" <0753xxxxx>', '0753xxxxx', 's', '202403190948560753xxxxx', 'dmse_IVR', 'PJSIP/registrar-00000001', '', 'Set', 'CDR(destination_number)=202403190948560753xxxxx', 0, 0, 'NO ANSWER', DOCUMENTATION, '', '1710821935.2', '011201xxxx', '1710821935.2')") in new stack
[Mar 19 09:48:56] WARNING[6388][C-00000002]: pbx_variables.c:1164 pbx_builtin_setvar: Please avoid unnecessary spaces on variables as it may lead to unexpected results ('ODBC_WRITE('', '"0753xxxxx" <0753xxxxx>', '0753xxxxx', 's', '2024031909485607538xxxxx', 'dmse_IVR', 'PJSIP/registrar-00000001', '', 'Set', 'CDR(destination_number)' set to '202403190948560753xxxx', 0, 0, 'NO ANSWER', DOCUMENTATION, '', '1710821935.2', '011201xxxx', '1710821935.2')').
[Mar 19 09:48:56] ERROR[6388][C-00000002]: pbx_functions.c:699 ast_func_write: Function ODBC_WRITE not registered
    -- Executing [s@dmse_IVR:11] Set("PJSIP/registrar-00000001", "tries=0") in new stack
    -- Executing [s@dmse_IVR:12] Goto("PJSIP/registrar-00000001", "testing,s,1") in new stack
    -- Goto (testing,s,1)
    -- Executing [s@testing:1] NoOp("PJSIP/registrar-00000001", "Incoming call to 'welcomeloop'") in new stack
    -- Executing [s@testing:2] WaitExten("PJSIP/registrar-00000001", "1") in new stack
    -- Timeout on PJSIP/registrar-00000001, continuing...
    -- Executing [s@testing:3] Monitor("PJSIP/registrar-00000001", "wav,20240319-094857-0753xxxxx-s,m") in new stack
    -- Executing [s@testing:4] BackGround("PJSIP/registrar-00000001", "welcomedmse") in new stack
    -- <PJSIP/registrar-00000001> Playing 'welcomedmse.adpcm' (language 'en')
       > 0x7f28a401b5a0 -- Strict RTP learning complete - Locking on source address 172.20.xx.xx:6030
    -- Executing [1@testing:1] NoOp("PJSIP/registrar-00000001", "User Pressed 1, Goto English menu") in new stack
    -- Executing [1@testing:2] Verbose("PJSIP/registrar-00000001", "1, User pressed 1") in new stack
  User pressed 1
    -- Executing [1@testing:3] Goto("PJSIP/registrar-00000001", "English_lang_testing,s,1") in new stack
    -- Goto (English_lang_testing,s,1)
    -- Executing [s@English_lang_testing:1] NoOp("PJSIP/registrar-00000001", "User Pressed 1 and go to English path") in new stack
    -- Executing [s@English_lang_testing:2] BackGround("PJSIP/registrar-00000001", "dmsevoice") in new stack
    -- <PJSIP/registrar-00000001> Playing 'dmsevoice.adpcm' (language 'en')
    -- Executing [1@English_lang_testing:1] NoOp("PJSIP/registrar-00000001", "User Pressed 1") in new stack
    -- Executing [1@English_lang_testing:2] Verbose("PJSIP/registrar-00000001", "1, User pressed 1") in new stack
  User pressed 1
    -- Executing [1@English_lang_testing:3] Set("PJSIP/registrar-00000001", "CONFID=1710821935.2") in new stack
    -- Executing [1@English_lang_testing:4] Answer("PJSIP/registrar-00000001", "") in new stack
    -- Executing [1@English_lang_testing:5] Verbose("PJSIP/registrar-00000001", "1, Call forwarding... one") in new stack
  Call forwarding... one
    -- Executing [1@English_lang_testing:6] Queue("PJSIP/registrar-00000001", "support,,,,120") in new stack
    -- Started music on hold, class 'default', on channel 'PJSIP/registrar-00000001'
    -- Stopped music on hold on PJSIP/registrar-00000001
  == Spawn extension (English_lang_testing, 1, 6) exited non-zero on 'PJSIP/registrar-00000001'

Lot doesn’t match dialplan. However, it doesn’t change my original response, that you really need to fix this at the phone.

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