首页 > 其他分享 >FreeSwitch:send_dtmf/uuid_send_dtmf发送按键注意事项

FreeSwitch:send_dtmf/uuid_send_dtmf发送按键注意事项

时间:2023-02-07 18:14:19浏览次数:69  
标签:27 uuid 08 29 send dtmf

很多时候我们打电话到公司前台,会听到类似“欢迎致电XXX,办公电话请直拨分机,咨询XX请按1,咨询YY请按2”这样的语音提示。在一些特定流程中,系统自动发起呼叫打到前台,希望实现自动按键(即:不用人手动按键),FreeSwitch提供了2个基本命令: send_dtmf及uuid_send_dtmf ,这2个基本功能一样,send_dtmf常用于ESL Outbound外联模式,不需要指定uuid,而uuid_send_dtmf则需要指定uuid.

 

以uuid_send_dtmf为例,演示下基本用法:(FreeSwitch控制台模式下)

1、先发起一个呼叫

1 freeswitch@xxx> create_uuid
2 4841d610-fba3-46b3-9432-4a4ebc164b36
3 
4 freeswitch@xxx> originate {origination_uuid=4841d610-fba3-46b3-9432-4a4ebc164b36}user/1000 &park()

 先生成一个uuid(方便后面uuid_send_dtmf时指定),然后用这个uuid,向内置用户1000发起呼叫,接通后park住,这样就有一个进行的通话了

 

2、模拟按键

1 uuid_send_dtmf 4841d610-fba3-46b3-9432-4a4ebc164b36 12

上图是freeswitch控制台的输出,有几个细节注意一下:

a) 按键是1个1个送出去的,即先送完1,再送2

b) 单个key发送完,会默认delay 40ms.

 

看上去很简单,对吧?继续折腾,uuid_send_dtmf 命令在按键后,还可以附加一个可选参数 tone_duration,

可以试下效果:

1 uuid_send_dtmf 4841d610-fba3-46b3-9432-4a4ebc164b36 12 300

猜猜是啥效果?

相当于发送了12300,是不是有点意外?

再试一下:

1 uuid_send_dtmf 4841d610-fba3-46b3-9432-4a4ebc164b36 12 @5000

这时候输出的内容太多,就不截完整的图了,输出片段如下:

---------------------------------------------------------------------------

freeswitch@xxx> uuid_send_dtmf 4841d610-fba3-46b3-9432-4a4ebc164b36 12 @5000
-ERR no reply

2021-08-29 16:27:05.188770 [DEBUG] switch_core_io.c:1894 sofia/internal/[email protected]:64045 send dtmf
digit=1 ms=5000 samples=40000
2021-08-29 16:27:05.188770 [DEBUG] switch_core_io.c:1894 sofia/internal/[email protected]:64045 send dtmf
digit=2 ms=5000 samples=40000
freeswitch@xxx> 2021-08-29 16:27:05.199769 [DEBUG] switch_rtp.c:5228 Send start packet for [1] ts=247200 dur=160/160/40000 seq=21903 lw=247200
2021-08-29 16:27:05.218781 [DEBUG] switch_rtp.c:5127 Send middle packet for [1] ts=247200 dur=320/320/40000 seq=21904 lw=247360
2021-08-29 16:27:05.238804 [DEBUG] switch_rtp.c:5127 Send middle packet for [1] ts=247200 dur=480/480/40000 seq=21905 lw=247520
2021-08-29 16:27:05.258771 [DEBUG] switch_rtp.c:5127 Send middle packet for [1] ts=247200 dur=640/640/40000 seq=21906 lw=247680
...

2021-08-29 16:27:10.178511 [DEBUG] switch_rtp.c:5127 Send end packet for [1] ts=247200 dur=40000/40000/40000 seq=22154 lw=286880
2021-08-29 16:27:10.178511 [DEBUG] switch_rtp.c:5075 Queue digit delay of 40ms
2021-08-29 16:27:10.579417 [DEBUG] switch_rtp.c:5228 Send start packet for [2] ts=287360 dur=160/160/40000 seq=22155 lw=287360
2021-08-29 16:27:10.598623 [DEBUG] switch_rtp.c:5127 Send middle packet for [2] ts=287360 dur=320/320/40000 seq=22156 lw=287520
2021-08-29 16:27:10.619422 [DEBUG] switch_rtp.c:5127 Send middle packet for [2] ts=287360 dur=480/480/40000 seq=22157 lw=287680
2021-08-29 16:27:10.639406 [DEBUG] switch_rtp.c:5127 Send middle packet for [2] ts=287360 dur=640/640/40000 seq=22158 lw=287840

...

---------------------------------------------------------------------------

指定了@5000后,每个按键的持续时间就变成了5秒了。

最后1个细节,实际使用中可能会遇到对方收的按键丢失,通常是发送太快,特别是号码中间有连续数字时,比如: 700001,发过去后,对方可能收到的是70001(少1个0)

uuid_send_dtmf Send DTMF digits to <uuid>   Usage: uuid_send_dtmf <uuid> <dtmf digits>[@<tone_duration>] Use the character w for a .5 second delay and the character W for a 1 second delay.   Default tone duration is 2000ms .

再反复阅读这段惜墨如金的官网文档(也没个示例,确实有点高深晦涩),其实这里给出了1个方法,在每个键后加小写w,可以在每次按键后,多delay 0.5s,如果是W,则多delay 1s,把刚才发送的按键12,改成1w2W试下

从图上看,1发送完后,多延时了500ms,而2发送完后,多延时了1000ms

 

小结一下:
1. 不加w或W, 每个按键默认delay 40ms间隔
2. 加W, 可delay 1s, 加w可delay 0.5s ,可以连续加, 比如1Ww2, 表示1之后delay 1+0.5s
3. @后的参数, 表示每个按键的持续时间

标签:27,uuid,08,29,send,dtmf
From: https://www.cnblogs.com/kn-zheng/p/17099362.html

相关文章