CDR: How to set the dial status of a channel to be the disposition value

I set CDR_PROP(party_a) to channel Local/s@ai_gateway_trunk-00000001;1
but disposition value is still ANSWERED. Can disposition be the dialstatus of any channel other than the first one?

this is logger log:

[2024-06-21 10:42:52] VERBOSE[766577] dial.c: Called s@ai_gateway_trunk
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] pbx.c: Executing [s@ai_gateway_trunk:1] Set("Local/s@ai_gateway_trunk-00000001;2", "JITTERBUFFER(adaptive)=default") in new stack
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] pbx.c: Executing [s@ai_gateway_trunk:2] Set("Local/s@ai_gateway_trunk-00000001;2", "VOLUME(TX)=3") in new stack
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] pbx.c: Executing [s@ai_gateway_trunk:3] Set("Local/s@ai_gateway_trunk-00000001;2", "VOLUME(RX)=3") in new stack
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] pbx.c: Executing [s@ai_gateway_trunk:4] Set("Local/s@ai_gateway_trunk-00000001;2", "CDR(call_id)=217337dc-09d7-489d-ae23-f52f95bfcfce") in new stack
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] pbx.c: Executing [s@ai_gateway_trunk:5] Set("Local/s@ai_gateway_trunk-00000001;2", "CDR(trunk_name)=000123456789") in new stack
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] pbx.c: Executing [s@ai_gateway_trunk:6] Set("Local/s@ai_gateway_trunk-00000001;2", "CDR(caller)=cloud_ai_gateway") in new stack
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] pbx.c: Executing [s@ai_gateway_trunk:7] Set("Local/s@ai_gateway_trunk-00000001;2", "CDR(callee)=0987654321") in new stack
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] pbx.c: Executing [s@ai_gateway_trunk:8] Set("Local/s@ai_gateway_trunk-00000001;2", "CDR(ai_scenario_id)=a9cf0440-d71b-4642-90cb-1dd064da16fb") in new stack
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] pbx.c: Executing [s@ai_gateway_trunk:9] Set("Local/s@ai_gateway_trunk-00000001;2", "direction=out") in new stack
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] pbx.c: Executing [s@ai_gateway_trunk:10] Set("Local/s@ai_gateway_trunk-00000001;2", "CDR(direction)=out") in new stack
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] pbx.c: Executing [s@ai_gateway_trunk:11] Verbose("Local/s@ai_gateway_trunk-00000001;2", "0,direction:out call_id:217337dc-09d7-489d-ae23-f52f95bfcfce caller:cloud_ai_gateway callee:0987654321 ai_scenario_id:a9cf0440-d71b-4642-90cb-1dd064da16fb") in new stack
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] app_verbose.c: direction:out call_id:217337dc-09d7-489d-ae23-f52f95bfcfce caller:cloud_ai_gateway callee:0987654321 ai_scenario_id:a9cf0440-d71b-4642-90cb-1dd064da16fb
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] pbx.c: Executing [s@ai_gateway_trunk:12] ExecIf("Local/s@ai_gateway_trunk-00000001;2", "1?System(/usr/bin/redis-cli -n 1 hmset 217337dc-09d7-489d-ae23-f52f95bfcfce ai_scenario_id a9cf0440-d71b-4642-90cb-1dd064da16fb)") in new stack
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] pbx.c: Executing [s@ai_gateway_trunk:13] System("Local/s@ai_gateway_trunk-00000001;2", "/usr/bin/redis-cli -n 1 hmset 217337dc-09d7-489d-ae23-f52f95bfcfce trunk_name 000123456789 direction out") in new stack
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] pbx.c: Executing [s@ai_gateway_trunk:14] Gosub("Local/s@ai_gateway_trunk-00000001;2", "outgoing,0987654321,1(,tm)") in new stack
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] pbx.c: Executing [0987654321@outgoing:1] Set("Local/s@ai_gateway_trunk-00000001;2", "ARRAY(__ai_scenario_id,__callee)=a9cf0440-d71b-4642-90cb-1dd064da16fb,0987654321") in new stack
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] pbx.c: Executing [0987654321@outgoing:2] Set("Local/s@ai_gateway_trunk-00000001;2", "number_of_trunks=1") in new stack
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] pbx.c: Executing [0987654321@outgoing:3] ExecIf("Local/s@ai_gateway_trunk-00000001;2", "0?Hangup(3)") in new stack
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] pbx.c: Executing [0987654321@outgoing:4] Set("Local/s@ai_gateway_trunk-00000001;2", "subfix=") in new stack
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] pbx.c: Executing [0987654321@outgoing:5] Dial("Local/s@ai_gateway_trunk-00000001;2", "PJSIP/000123456789@000123456789,,tmb(pre_dial_jitter_buffer^s^1)g") in new stack
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] app_stack.c: PJSIP/000123456789-00000001 Internal Gosub(pre_dial_jitter_buffer,s,1) start
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] pbx.c: Executing [s@pre_dial_jitter_buffer:1] Set("PJSIP/000123456789-00000001", "JITTERBUFFER(adaptive)=default") in new stack
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] pbx.c: Executing [s@pre_dial_jitter_buffer:2] Set("PJSIP/000123456789-00000001", "DENOISE(rx)=on") in new stack
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] pbx.c: Executing [s@pre_dial_jitter_buffer:3] Set("PJSIP/000123456789-00000001", "DENOISE(tx)=on") in new stack
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] pbx.c: Executing [s@pre_dial_jitter_buffer:4] Set("PJSIP/000123456789-00000001", "PJSIP_HEADER(add,x-cloud-call-bot-proxy-scenario-id)=a9cf0440-d71b-4642-90cb-1dd064da16fb") in new stack
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] pbx.c: Executing [s@pre_dial_jitter_buffer:5] Set("PJSIP/000123456789-00000001", "PJSIP_HEADER(add,x-cloud-call-bot-proxy-callee)=0987654321") in new stack
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] pbx.c: Executing [s@pre_dial_jitter_buffer:6] Return("PJSIP/000123456789-00000001", "") in new stack
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] app_stack.c: Spawn extension (default, 0987654321, 1) exited non-zero on 'PJSIP/000123456789-00000001'
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] app_stack.c: PJSIP/000123456789-00000001 Internal Gosub(pre_dial_jitter_buffer,s,1) complete GOSUB_RETVAL=
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] app_dial.c: Called PJSIP/000123456789@000123456789
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] res_musiconhold.c: Started music on hold, class 'default', on channel 'Local/s@ai_gateway_trunk-00000001;2'
[2024-06-21 10:42:52] VERBOSE[766577] dial.c: Local/s@ai_gateway_trunk-00000001;1 is making progress
[2024-06-21 10:42:52] VERBOSE[742838] res_rtp_asterisk.c: 0x7fd88406dae0 -- Strict RTP learning after remote address set to: 123.31.11.194:28286
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] app_dial.c: PJSIP/000123456789-00000001 is making progress passing it to Local/s@ai_gateway_trunk-00000001;2
[2024-06-21 10:42:52] VERBOSE[766577] dial.c: Local/s@ai_gateway_trunk-00000001;1 is making progress
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] app_dial.c: PJSIP/000123456789-00000001 is making progress passing it to Local/s@ai_gateway_trunk-00000001;2
[2024-06-21 10:42:52] VERBOSE[766577] dial.c: Local/s@ai_gateway_trunk-00000001;1 is making progress
[2024-06-21 10:42:52] VERBOSE[766578][C-00000003] res_rtp_asterisk.c: 0x7fd88406dae0 -- Strict RTP switching to RTP target address 123.31.11.194:28286 as source
[2024-06-21 10:42:54] VERBOSE[766578][C-00000003] app_dial.c: PJSIP/000123456789-00000001 answered Local/s@ai_gateway_trunk-00000001;2
[2024-06-21 10:42:54] VERBOSE[766578][C-00000003] res_musiconhold.c: Stopped music on hold on Local/s@ai_gateway_trunk-00000001;2
[2024-06-21 10:42:54] VERBOSE[766577] dial.c: Local/s@ai_gateway_trunk-00000001;1 answered
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [s@ai_gateway_bot:1] Set("Local/s@ai_gateway_trunk-00000001;1", "ARRAY(direction,CDR(userfield),CDR_PROP(party_a))=out,final,true") in new stack
[2024-06-21 10:42:54] VERBOSE[766690][C-00000003] bridge_channel.c: Channel PJSIP/000123456789-00000001 joined 'simple_bridge' basic-bridge <3e766ec6-49c7-43a1-9521-e70ee4685309>
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [s@ai_gateway_bot:2] Set("Local/s@ai_gateway_trunk-00000001;1", "caller=cloud_ai_gateway") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [s@ai_gateway_bot:3] Gosub("Local/s@ai_gateway_trunk-00000001;1", "ai_gateway,s,1") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [s@ai_gateway:1] Set("Local/s@ai_gateway_trunk-00000001;1", "JITTERBUFFER(adaptive)=default") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [s@ai_gateway:2] GotoIf("Local/s@ai_gateway_trunk-00000001;1", "1?keep_processing") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx_builtins.c: Goto (ai_gateway,s,5)
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [s@ai_gateway:5] ExecIf("Local/s@ai_gateway_trunk-00000001;1", "0?System(/usr/bin/redis-cli -n 10 hmset 217337dc-09d7-489d-ae23-f52f95bfcfce reconnect 1)") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [s@ai_gateway:6] Set("Local/s@ai_gateway_trunk-00000001;1", "CDR(call_id)=217337dc-09d7-489d-ae23-f52f95bfcfce") in new stack
[2024-06-21 10:42:54] VERBOSE[766578][C-00000003] bridge_channel.c: Channel Local/s@ai_gateway_trunk-00000001;2 joined 'simple_bridge' basic-bridge <3e766ec6-49c7-43a1-9521-e70ee4685309>
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [s@ai_gateway:7] Set("Local/s@ai_gateway_trunk-00000001;1", "CDR(trunk_name)=000123456789") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [s@ai_gateway:8] Set("Local/s@ai_gateway_trunk-00000001;1", "CDR(caller)=cloud_ai_gateway") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [s@ai_gateway:9] Set("Local/s@ai_gateway_trunk-00000001;1", "CDR(callee)=0987654321") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [s@ai_gateway:10] Set("Local/s@ai_gateway_trunk-00000001;1", "CDR(ai_scenario_id)=a9cf0440-d71b-4642-90cb-1dd064da16fb") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [s@ai_gateway:11] Set("Local/s@ai_gateway_trunk-00000001;1", "CDR(direction)=out") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [s@ai_gateway:12] Verbose("Local/s@ai_gateway_trunk-00000001;1", "0,direction:out call_id:217337dc-09d7-489d-ae23-f52f95bfcfce caller:cloud_ai_gateway callee:0987654321 ai_scenario_id:a9cf0440-d71b-4642-90cb-1dd064da16fb") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] app_verbose.c: direction:out call_id:217337dc-09d7-489d-ae23-f52f95bfcfce caller:cloud_ai_gateway callee:0987654321 ai_scenario_id:a9cf0440-d71b-4642-90cb-1dd064da16fb
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [s@ai_gateway:13] Set("Local/s@ai_gateway_trunk-00000001;1", "VOLUME(TX)=3") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [s@ai_gateway:14] Set("Local/s@ai_gateway_trunk-00000001;1", "VOLUME(RX)=3") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [s@ai_gateway:15] Set("Local/s@ai_gateway_trunk-00000001;1", "DENOISE(rx)=on") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [s@ai_gateway:16] Set("Local/s@ai_gateway_trunk-00000001;1", "DENOISE(tx)=on") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [s@ai_gateway:17] ExecIf("Local/s@ai_gateway_trunk-00000001;1", "1?System(/usr/bin/redis-cli -n 1 hmset 217337dc-09d7-489d-ae23-f52f95bfcfce ai_scenario_id a9cf0440-d71b-4642-90cb-1dd064da16fb)") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [s@ai_gateway:18] System("Local/s@ai_gateway_trunk-00000001;1", "/usr/bin/redis-cli -n 1 hmset 217337dc-09d7-489d-ae23-f52f95bfcfce trunk_name 000123456789 direction out") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [s@ai_gateway:19] Dial("Local/s@ai_gateway_trunk-00000001;1", "AudioSocket/10.5.82.143:5800/217337dc-09d7-489d-ae23-f52f95bfcfce/c(slin),,g") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] app_dial.c: Everyone is busy/congested at this time (1:0/0/1)
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [s@ai_gateway:20] Goto("Local/s@ai_gateway_trunk-00000001;1", "h,1") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx_builtins.c: Goto (ai_gateway,h,1)
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [h@ai_gateway:1] System("Local/s@ai_gateway_trunk-00000001;1", "/usr/bin/redis-cli -n 2 blpush call_data ") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [h@ai_gateway:2] Return("Local/s@ai_gateway_trunk-00000001;1", "") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [s@ai_gateway_bot:4] Set("Local/s@ai_gateway_trunk-00000001;1", "event=") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [s@ai_gateway_bot:5] GotoIf("Local/s@ai_gateway_trunk-00000001;1", "0?ivr") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [s@ai_gateway_bot:6] GotoIf("Local/s@ai_gateway_trunk-00000001;1", "0?diverting_calls") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [s@ai_gateway_bot:7] Goto("Local/s@ai_gateway_trunk-00000001;1", "h,1") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx_builtins.c: Goto (ai_gateway_bot,h,1)
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [h@ai_gateway_bot:1] NoOp("Local/s@ai_gateway_trunk-00000001;1", "DIALSTATUS:CHANUNAVAIL | CDR(disposition):ANSWERED") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [h@ai_gateway_bot:2] System("Local/s@ai_gateway_trunk-00000001;1", "/usr/bin/redis-cli -n 2 blpush call_data ") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [h@ai_gateway_bot:3] Hangup("Local/s@ai_gateway_trunk-00000001;1", "") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Spawn extension (ai_gateway_bot, h, 3) exited non-zero on 'Local/s@ai_gateway_trunk-00000001;1'
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [h@ai_gateway_bot:1] NoOp("Local/s@ai_gateway_trunk-00000001;1", "DIALSTATUS:CHANUNAVAIL | CDR(disposition):ANSWERED") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [h@ai_gateway_bot:2] System("Local/s@ai_gateway_trunk-00000001;1", "/usr/bin/redis-cli -n 2 blpush call_data ") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Executing [h@ai_gateway_bot:3] Hangup("Local/s@ai_gateway_trunk-00000001;1", "") in new stack
[2024-06-21 10:42:54] VERBOSE[766577][C-00000004] pbx.c: Spawn extension (ai_gateway_bot, h, 3) exited non-zero on 'Local/s@ai_gateway_trunk-00000001;1'
[2024-06-21 10:42:54] VERBOSE[766578][C-00000003] bridge_channel.c: Channel Local/s@ai_gateway_trunk-00000001;2 left 'simple_bridge' basic-bridge <3e766ec6-49c7-43a1-9521-e70ee4685309>
[2024-06-21 10:42:54] VERBOSE[766690][C-00000003] bridge_channel.c: Channel PJSIP/000123456789-00000001 left 'simple_bridge' basic-bridge <3e766ec6-49c7-43a1-9521-e70ee4685309>
[2024-06-21 10:42:54] VERBOSE[766578][C-00000003] pbx.c: Spawn extension (outgoing, 0987654321, 5) exited non-zero on 'Local/s@ai_gateway_trunk-00000001;2'
[2024-06-21 10:42:54] VERBOSE[766578][C-00000003] pbx.c: Executing [h@outgoing:1] Return("Local/s@ai_gateway_trunk-00000001;2", "") in new stack
[2024-06-21 10:42:54] VERBOSE[766578][C-00000003] pbx.c: Executing [s@ai_gateway_trunk:15] GotoIf("Local/s@ai_gateway_trunk-00000001;2", "1?h,1") in new stack
[2024-06-21 10:42:54] VERBOSE[766578][C-00000003] pbx_builtins.c: Goto (ai_gateway_trunk,h,1)
[2024-06-21 10:42:54] VERBOSE[766578][C-00000003] pbx.c: Executing [h@ai_gateway_trunk:1] Hangup("Local/s@ai_gateway_trunk-00000001;2", "") in new stack
[2024-06-21 10:42:54] VERBOSE[766578][C-00000003] pbx.c: Spawn extension (ai_gateway_trunk, h, 1) exited non-zero on 'Local/s@ai_gateway_trunk-00000001;2'

my dialplan:

[ai_gateway]
exten => s,1,Set(JITTERBUFFER(adaptive)=default)
 same => n,GotoIf($["${CHANNEL:0:5}"!="PJSIP"]?keep_processing)
 ; setup inbound call, get variables from sip header
 same => n,Set(reconnect=${PJSIP_HEADER(read,x-cloud-call-bot-proxy-reconnect)})
 same => n,Set(ai_scenario_id=${PJSIP_HEADER(read,x-cloud-call-bot-proxy-scenario-id)})

 same => n(keep_processing),ExecIf($["${reconnect}" != ""]?System(/usr/bin/redis-cli -n 10 hmset ${uuid} reconnect 1))
 same => n,Set(CDR(call_id)=${uuid})
 same => n,Set(CDR(trunk_name)=${trunk_name})
 same => n,Set(CDR(caller)=${caller})
 same => n,Set(CDR(callee)=${callee})
 same => n,Set(CDR(ai_scenario_id)=${ai_scenario_id})
 same => n,Set(CDR(direction)=${direction})
; same => n,Set(CDR(disposition)=BUSY)
 same => n,Verbose(0,direction:${direction} call_id:${uuid} caller:${caller} callee:${callee} ai_scenario_id:${ai_scenario_id})
 same => n,Set(VOLUME(TX)=3)
 same => n,Set(VOLUME(RX)=3)
 same => n,Set(DENOISE(rx)=on)
 same => n,Set(DENOISE(tx)=on)
 same => n,ExecIf($["${ai_scenario_id}"!=""]?System(/usr/bin/redis-cli -n 1 hmset ${uuid} ai_scenario_id ${ai_scenario_id}))
 same => n,System(/usr/bin/redis-cli -n 1 hmset ${uuid} trunk_name ${trunk_name} direction ${direction})
; same => n,Answer()
 same => n,Dial(AudioSocket/10.5.82.143:5800/${uuid}/c(slin),${caller_timeout},g)
 same => n,Goto(h,1)

exten => h,1,System(/usr/bin/redis-cli -n 2 blpush call_data ${call_id})
 same => n,Return()


[ai_gateway_bot]
exten => s,1,Set(ARRAY(direction,CDR(userfield),CDR_PROP(party_a))=out,final,true)
 same => n,Set(caller=cloud_ai_gateway)
 same => n,Gosub(ai_gateway,s,1)
 same => n,Set(event=${SHELL(/usr/bin/redis-cli -n 10 hget ${uuid} event):0:-1})
 same => n,GotoIf($["${event}"="ivr"]?ivr)
 same => n,GotoIf($["${event}"="diverting_calls"]?diverting_calls)
 same => n,Goto(h,1)

 same => n(ivr),Set(ivr_timeout=${SHELL(/usr/bin/redis-cli -n 10 hget ${uuid} ivr_timeout):0:-1})
 same => n,SendText(event=ivr,timeout=${ivr_timeout})
 same => n,Goto(h,1)

 same => n(diverting_calls),Set(redirect_type=${SHELL(/usr/bin/redis-cli -n 10 hget ${uuid} redirect_type):0:-1})
 same => n,Set(timeout=${SHELL(/usr/bin/redis-cli -n 10 hget ${uuid} timeout):0:-1})
 same => n,GotoIf($["${redirect_type}"="callee"]?callee:callee_group)

 same => n(callee),Set(callee=${SHELL(/usr/bin/redis-cli -n 10 hget ${uuid} callee):0:-1})
 same => n,SendText(event=diverting_calls,redirect_type=callee,callee=${callee},timeout=${timeout})
 same => n,Goto(h,1)

 same => n(callee_group),Set(callee_group_id=${SHELL(/usr/bin/redis-cli -n 10 hget ${uuid} callee_group_id):0:-1})
 same => n,SendText(event=diverting_calls,redirect_type=callee_group,callee_group_id=${callee},timeout=${timeout})
 same => n,Goto(h,1)

exten => h,1,NoOp(DIALSTATUS:${DIALSTATUS} | CDR(disposition):${CDR(disposition)})
 same => n,System(/usr/bin/redis-cli -n 2 blpush call_data ${call_id})
 same => n,Hangup()


[ai_gateway_trunk]
exten => s,1,Set(JITTERBUFFER(adaptive)=default)
 same => n,Set(VOLUME(TX)=3)
 same => n,Set(VOLUME(RX)=3)
 same => n,Set(CDR(call_id)=${uuid})
 same => n,Set(CDR(trunk_name)=${trunk_name})
 same => n,Set(CDR(caller)=${caller})
 same => n,Set(CDR(callee)=${callee})
 same => n,Set(CDR(ai_scenario_id)=${ai_scenario_id})
 same => n,Set(direction=out)
 same => n,Set(CDR(direction)=${direction})
 same => n,Verbose(0,direction:${direction} call_id:${uuid} caller:${caller} callee:${callee} ai_scenario_id:${ai_scenario_id})
 same => n,ExecIf($["${ai_scenario_id}"!=""]?System(/usr/bin/redis-cli -n 1 hmset ${uuid} ai_scenario_id ${ai_scenario_id}))
 same => n,System(/usr/bin/redis-cli -n 1 hmset ${uuid} trunk_name ${trunk_name} direction ${direction})
 ; call the caller
 same => n,Gosub(outgoing,${callee},1(${timeout},tm))
 same => n,GotoIf($["${DIALSTATUS}" = "ANSWER"]?h,1)
 same => n,System(/usr/bin/redis-cli -n 2 blpush call_data ${call_id})
 same => n,Goto(h,1)

exten => h,1,Hangup()


;================================REALTIME-CONFIG================================
[default]
switch => Realtime/@/p

exten => i,1,Hangup()
exten => e,1,Hangup()
exten => h,1,Verbose(0,caller_hangup:1)
 same => n,Set(caller_hangup=1)
 same => n,Hangup()
exten => T,1,Hangup()
exten => t,1,Hangup()


;================================DEFAULT CONFIG=================================
[pre_dial_jitter_buffer]
; setup jitter buffer to improve media quality
exten => s,1,Set(JITTERBUFFER(adaptive)=default)
 same => n,Set(DENOISE(rx)=on)
 same => n,Set(DENOISE(tx)=on)
 same => n,Set(PJSIP_HEADER(add,x-cloud-call-bot-proxy-scenario-id)=${ai_scenario_id})
 same => n,Set(PJSIP_HEADER(add,x-cloud-call-bot-proxy-callee)=${callee})
 same => n,Return()

exten => i,1,Return()
exten => h,1,Return()
exten => e,1,Return()
exten => T,1,Return()
exten => t,1,Return()


[outgoing]
; call all trunk, including backup trunk
exten => _X.,1,Set(ARRAY(__ai_scenario_id,__callee)=${ai_scenario_id},${EXTEN})
 same => n(call_process),Set(number_of_trunks=${ODBC_GET_TRUNKS(${trunk_name})})
 same => n(loop),ExecIf($[${number_of_trunks}=0]?Hangup(3))
 same => n,Set(subfix=${IF($[${number_of_trunks}=1]?:-$[${number_of_trunks} - 1])})
; use a flag which is set earlier to name all the trunks?
 same => n,Dial(PJSIP/${trunk_name}@${trunk_name}${subfix},${ARG1},${ARG2}b(pre_dial_jitter_buffer^s^1)g)
 same => n,Set(number_of_trunks=$[${number_of_trunks} - 1])
 same => n,Set(subfix=)
 same => n,NoOp(DIALSTATUS:${DIALSTATUS} | HANGUPCAUSE:${HANGUPCAUSE})
 same => n,Set(DIAL_RESULT=$["${DIALSTATUS}" : "^(ANSWER|NOANSWER|BUSY|CANCEL)$"])
 same => n,GotoIf($["${DIAL_RESULT}" = ""]?loop)
 same => n,Return()

exten => i,1,Return()
exten => h,1,Return()
exten => e,1,Return()
exten => T,1,Return()
exten => t,1,Return()

my originate:

endpoint: Local/s@ai_gateway_trunk
extension: s
context: ai_gateway_bot
priority: 1

The call is answered. Asterisk is doing the correct thing by logging it as ANSWERED.

You might try adding additional helper channels that answer separately without affecting the main channel. But it is not clear why there is a problem.

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