介绍
http bridge 的原理是cti模块实现了一个cti_bridge的FreeSWITCH APP,可以在呼出之前调用HTTP接口获取呼出参数,可用于实现小号业务,隐私号业务等外呼之前动态绑定主叫和被叫号码,也可用于呼入业务由HTTP接口控制呼入转接规则。
配置
<action application="cti_bridge" data="http://ip/binding?number=${destination_number}&callerid={caller_id_number} connect_timeout response_timeout notify_type"/>
- 第一个参数 请求的URL,URL和参数可自定义
- 第二个参数 connect_timeout 连接超时 单位毫秒,默认3000
- 第三个参数 response_timeout 等待http接口响应的超时 单位毫秒 默认 3000
- 第四个参数 notify_type 0:不要呼叫进度通知 1:需要呼叫进度通知,默认1
接口说明
接收到一个呼入后,cti_bridge会把呼叫信息送给接口,接口返回转接信息。以下是返回信息说明
通用用参数说明
variables 可用于设置通道变量,比如主叫号码(origination_caller_id_number),编码(absolute_codec_string)等
number 转接号码(被叫号码)
通过网关呼出 gateway网关名,number被叫号码
{
"variables": {
"origination_caller_id_number": "123",
"absolute_codec_string": "PCMA,PCMU"
},
"dial": {
"type": "gateway",
"number": "123456",
"gateway": "gw"
}
}
通过注册分机呼出,一般用于注册方式对接到fs,user注册的分机号
{
"dial": {
"type": "user",
"number": "123456",
"user": "1000"
}
}
通过IP直接呼出,ip中继|VOS|网关的IP:PORT
{
"dial": {
"type": "ip",
"number": "123456",
"ip": "网关IP",
"sofia": "external"
}
}
通过自定义拨号串呼出,
{
"dial": {
"type": "dialstring",
"dialstring": "sofia/external/158@ip:port"
}
}
顺序转接给多个号码,第一个号码呼叫失败,继续转接给第二个号码
{
"dial": {
"type": "dialstring",
"dialstring": "{ignore_early_media=true}sofia/gateway/网关1/号码1,sofia/gateway/网关2/号码2"
}
}
不转接,直接挂断
{
"dial": {
"type": "hangup",
"cause": 16,
"sipcode": 500
}
}
cause和sipcode只需要配置一个,sipcode就是SIP代码·cause 取值说明:
typedef enum {
SWITCH_CAUSE_NONE = 0,
SWITCH_CAUSE_UNALLOCATED_NUMBER = 1,
SWITCH_CAUSE_NO_ROUTE_TRANSIT_NET = 2,
SWITCH_CAUSE_NO_ROUTE_DESTINATION = 3,
SWITCH_CAUSE_CHANNEL_UNACCEPTABLE = 6,
SWITCH_CAUSE_CALL_AWARDED_DELIVERED = 7,
SWITCH_CAUSE_NORMAL_CLEARING = 16,
SWITCH_CAUSE_USER_BUSY = 17,
SWITCH_CAUSE_NO_USER_RESPONSE = 18,
SWITCH_CAUSE_NO_ANSWER = 19,
SWITCH_CAUSE_SUBSCRIBER_ABSENT = 20,
SWITCH_CAUSE_CALL_REJECTED = 21,
SWITCH_CAUSE_NUMBER_CHANGED = 22,
SWITCH_CAUSE_REDIRECTION_TO_NEW_DESTINATION = 23,
SWITCH_CAUSE_EXCHANGE_ROUTING_ERROR = 25,
SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER = 27,
SWITCH_CAUSE_INVALID_NUMBER_FORMAT = 28,
SWITCH_CAUSE_FACILITY_REJECTED = 29,
SWITCH_CAUSE_RESPONSE_TO_STATUS_ENQUIRY = 30,
SWITCH_CAUSE_NORMAL_UNSPECIFIED = 31,
SWITCH_CAUSE_NORMAL_CIRCUIT_CONGESTION = 34,
SWITCH_CAUSE_NETWORK_OUT_OF_ORDER = 38,
SWITCH_CAUSE_NORMAL_TEMPORARY_FAILURE = 41,
SWITCH_CAUSE_SWITCH_CONGESTION = 42,
SWITCH_CAUSE_ACCESS_INFO_DISCARDED = 43,
SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL = 44,
SWITCH_CAUSE_PRE_EMPTED = 45,
SWITCH_CAUSE_FACILITY_NOT_SUBSCRIBED = 50,
SWITCH_CAUSE_OUTGOING_CALL_BARRED = 52,
SWITCH_CAUSE_INCOMING_CALL_BARRED = 54,
SWITCH_CAUSE_BEARERCAPABILITY_NOTAUTH = 57,
SWITCH_CAUSE_BEARERCAPABILITY_NOTAVAIL = 58,
SWITCH_CAUSE_SERVICE_UNAVAILABLE = 63,
SWITCH_CAUSE_BEARERCAPABILITY_NOTIMPL = 65,
SWITCH_CAUSE_CHAN_NOT_IMPLEMENTED = 66,
SWITCH_CAUSE_FACILITY_NOT_IMPLEMENTED = 69,
SWITCH_CAUSE_SERVICE_NOT_IMPLEMENTED = 79,
SWITCH_CAUSE_INVALID_CALL_REFERENCE = 81,
SWITCH_CAUSE_INCOMPATIBLE_DESTINATION = 88,
SWITCH_CAUSE_INVALID_MSG_UNSPECIFIED = 95,
SWITCH_CAUSE_MANDATORY_IE_MISSING = 96,
SWITCH_CAUSE_MESSAGE_TYPE_NONEXIST = 97,
SWITCH_CAUSE_WRONG_MESSAGE = 98,
SWITCH_CAUSE_IE_NONEXIST = 99,
SWITCH_CAUSE_INVALID_IE_CONTENTS = 100,
SWITCH_CAUSE_WRONG_CALL_STATE = 101,
SWITCH_CAUSE_RECOVERY_ON_TIMER_EXPIRE = 102,
SWITCH_CAUSE_MANDATORY_IE_LENGTH_ERROR = 103,
SWITCH_CAUSE_PROTOCOL_ERROR = 111,
SWITCH_CAUSE_INTERWORKING = 127,
SWITCH_CAUSE_SUCCESS = 142,
SWITCH_CAUSE_ORIGINATOR_CANCEL = 487,
SWITCH_CAUSE_CRASH = 500,
SWITCH_CAUSE_SYSTEM_SHUTDOWN = 501,
SWITCH_CAUSE_LOSE_RACE = 502,
SWITCH_CAUSE_MANAGER_REQUEST = 503,
SWITCH_CAUSE_BLIND_TRANSFER = 600,
SWITCH_CAUSE_ATTENDED_TRANSFER = 601,
SWITCH_CAUSE_ALLOTTED_TIMEOUT = 602,
SWITCH_CAUSE_USER_CHALLENGE = 603,
SWITCH_CAUSE_MEDIA_TIMEOUT = 604,
SWITCH_CAUSE_PICKED_OFF = 605,
SWITCH_CAUSE_USER_NOT_REGISTERED = 606,
SWITCH_CAUSE_PROGRESS_TIMEOUT = 607,
SWITCH_CAUSE_INVALID_GATEWAY = 608,
SWITCH_CAUSE_GATEWAY_DOWN = 609,
SWITCH_CAUSE_INVALID_URL = 610,
SWITCH_CAUSE_INVALID_PROFILE = 611,
SWITCH_CAUSE_NO_PICKUP = 612,
SWITCH_CAUSE_SRTP_READ_ERROR = 613
} switch_call_cause_t;
进度通知
http://url&action=request&uuid=xxxx
URL 就是cti_bridge配置的URL
action
- request 请求转接参数
- hangup 通话挂断
- ring 收到180
- progress 收到183
- answer 通话应答
uuid 通话UUID