【FreeSwitch开发实践】外呼网关配置(拨打电话)
? 博客主頁:小小馬車夫的主頁
? 所屬專欄:FreeSwitch開發實踐
? 專欄介紹:主要介紹博主在實際項目中使用FreeSwitch開發外呼類項目的一些經驗心得,主要涉及FreeSwitch的基本安裝編譯、基本配置、ESL、WSS、錄音、自定義模塊、media bug、語音播放、MRCP及對接AI機器人等內容。內容在持續更新中,如果感興趣可以對專欄進行訂閱~
文章目錄
- 前言
- 1、SIP網關配置
- (1) 注冊模式
- 配置
- 加載網關配置
- (2) 非注冊模式
- 配置
- 加載網關配置
- 3、撥號計劃配置
- (1) 呼出配置
- (2) 呼入配置
- 總結
前言
FreeSwitch開發一個重要應用是外呼,所謂外呼就撥打真實電話或手機號呼叫,配合語音機器人可以實現智能客服的功能。外呼配置主要是配置外呼服務器,外呼服務器主要指SIP網關,每個外呼服務器就是一個SIP節點,FreeSwitch服務也可以是一個SIP節點。
1、SIP網關配置
sip網關配置有兩種模式,注冊模式和非注冊模式,下面分別對兩種模式配置說明。
(1) 注冊模式
注冊模式下,需要一個密碼:
配置
在FreeSwitch目錄在conf\sip_profiles\external 創建文件,隨便取個名字,如: my_gate.xml, 內容如下:
<include><gateway name="mygate_register"><param name="realm" value="100.200.252.125:5060"/><param name="username" value="01012345678"/> <param name="password" value="123456"/> <param name="register" value="true"/></gateway> </include>說明:
- gateway 網關定義,name 是網關配置名稱,在撥號時用到
- realm SIP網關的IP和端口, 其中IP可以替換為域名
- username 是就外呼撥號時被叫手機看到的來電號碼
- password 是SIP網關認證的密碼
- register 布爾類型, true=注冊類型 false=非注冊類型
加載網關配置
在FreeSwitch命令行運行如下命令:
freeswitch@test-l27-15-56> sofia statusName Type Data State =================================================================================================external-ipv6 profile sip:mod_sofia@[::1]:5080 RUNNING (0)external-ipv6 profile sip:mod_sofia@[::1]:5081 RUNNING (0) (TLS)10.32.22.12 alias internal ALIASEDexternal profile sip:mod_sofia@10.32.22.12:5080 RUNNING (0)external profile sip:mod_sofia@10.32.22.12:5081 RUNNING (0) (TLS)external::mygate gateway sip:01012345678@100.200.252.125:5060 REGinternal-ipv6 profile sip:mod_sofia@[::1]:5060 RUNNING (0)internal-ipv6 profile sip:mod_sofia@[::1]:5061 RUNNING (0) (TLS)internal profile sip:mod_sofia@10.32.22.12:5060 RUNNING (0)internal profile sip:mod_sofia@10.32.22.12:5061 RUNNING (0) (TLS) ================================================================================================= 4 profiles 1 alias(2) 非注冊模式
非注冊模式下,不需要密碼。
配置
在FreeSwitch目錄在conf\sip_profiles\external 創建文件,隨便取個名字,如: my_gate.xml, 內容如下:
<include><gateway name="mygate"><param name="realm" value="100.200.252.125:5060"/><param name="username" value="01012345678"/> <param name="register" value="false"/></gateway> </include>這里與注冊模式的區別就是:register為false
加載網關配置
在FreeSwitch命令行運行如下命令:
freeswitch@test-l27-15-56> sofia statusName Type Data State =================================================================================================external-ipv6 profile sip:mod_sofia@[::1]:5080 RUNNING (0)external-ipv6 profile sip:mod_sofia@[::1]:5081 RUNNING (0) (TLS)10.32.22.12 alias internal ALIASEDexternal profile sip:mod_sofia@10.32.22.12:5080 RUNNING (0)external profile sip:mod_sofia@10.32.22.12:5081 RUNNING (0) (TLS)external::example.com gateway sip:joeuser@example.com NOREGexternal::mygate gateway sip:01012345678@100.200.252.125:5060 NOREGinternal-ipv6 profile sip:mod_sofia@[::1]:5060 RUNNING (0)internal-ipv6 profile sip:mod_sofia@[::1]:5061 RUNNING (0) (TLS)internal profile sip:mod_sofia@10.32.22.12:5060 RUNNING (0)internal profile sip:mod_sofia@10.32.22.12:5061 RUNNING (0) (TLS) ================================================================================================= 4 profiles 1 alias3、撥號計劃配置
(1) 呼出配置
呼出配置,即往外呼叫,呼叫的對象就是SIP網關配置的外呼號碼,具體配置示例如下:
在conf\dialplan\default下創建路由配置文件 mycall.xml, 內容如下:
- destination_number 為撥號正則表達式
- sofia/gateway/mygate/$1 其中,mygate是前面SIP網關配置的名字, $1為正則表達式中(\d+)部分
呼叫命令舉例:
originate user/1000 018600000001- user/1000 為軟電話1000
- 018600000001,為前面所述配置的正則,本例中 $1為18600000001,就是手機號碼
(2) 呼入配置
呼入配置,即往內呼叫,就是真實手機號碼呼叫到FS,由于FreeSwitch是背靠背協議,所以兩端通信時,呼入和呼出配置基本沒有區別。但當呼入配置的對象是FreeSwitch的內置模塊(app)或者自定義模塊,確很有用。
呼入命令舉例:
- 示例中sofia/gateway/mygate為配置的網關
- 18600000001 為手機號碼,不同于呼出配置,這里直接使用手機號碼
- echo為FreeSwitch內置模塊echo, 回音程序,當然也可以自己開發的模塊
總結
本文主要介紹了FreeSwitch外呼相關配置,主要有
- 外呼配置的模式,包括注冊模式和非注冊模式
- 網關加載的查看方法
- 撥號中常見的呼出配置和呼入配置
如果覺得有些幫助或覺得文章還不錯,請關注一下博主,你的關注是我持續寫作的動力。另外,如果有什么問題,可以在評論區留言,或者私信博主,博主看到后會第一時間回復。
【間歇性的努力和蒙混過日子,都是對之前努力的清零】
歡迎轉載,轉載請注明出處:https://blog.csdn.net/xxm524/article/details/126328064
總結
以上是生活随笔為你收集整理的【FreeSwitch开发实践】外呼网关配置(拨打电话)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: bat批处理开发-wifi联网系列(4)
- 下一篇: 课程设计技术小结