我正在将 ami-io 库与 Node.js 一起使用。我正在发送带有上下文的发起呼叫,用于将应答的呼叫重定向到 ivr。有 2 个 ivrs 用于不同目的。另外,我将 Lead_id 设置为通道来处理结果,但上下文存在问题。即使我发送了自定义上下文,呼叫也会使用 from-trunk-sip-{callerid} 上下文进行。因此,我无法将 Lead_id 设置为频道。我的上下文仅在应答呼叫时才处于活动状态。我想设置 Lead_id 来引导呼叫是否被应答。
这是上下文和 ami-io 代码。
背景:
[type1-ivr-forward]
exten => _X.,1,NoOp(Calls for IVR)
same => n,Set(LEAD_ID=${IF($[${LEN(${lead_id})} > 0]?${lead_id}:UNKNOWN)})
same => n,Set(CHANNEL(accountcode)=${LEAD_ID})
same => n,NoOp(Lead ID: ${LEAD_ID})
same => n,Answer()
same => n,Goto(ivr-1,s,1)
[type2-ivr-forward]
exten => _X.,1,NoOp(Calls for IVR)
same => n,Set(LEAD_ID=${IF($[${LEN(${lead_id})} > 0]?${lead_id}:UNKNOWN)})
same => n,Set(CHANNEL(accountcode)=${LEAD_ID})
same => n,NoOp(Lead ID: ${LEAD_ID})
same => n,Answer()
same => n,Set(CALLERID(num)=${customer_phone})
same => n,Goto(ivr-2,s,1)
Node.js
async function call(lead_data) {
var action = new amiio.Action.Originate();
action.Channel = `SIP/${lead_data.caller_id}/${lead_data.phone_number}`;
action.Context = `${lead_data.type}-ivr-forward`; // type 1 or type 2
action.Exten = '1003';
action.Priority = 1;
action.Async = true;
action.WaitEvent = true;
action.CallerId = `${lead_data.caller_id}`;
action.Timeout = 30000;
action.variables = { lead_id: lead_data.lead_id, customer_phone: lead_data.phone_number };
client.send(action, async function (err, data) {
if (err) {
// success actions
} else {
// error actions
}
});
}
如果您想在第一段应答之前控制任何操作,您应该通过环回 - 本地通道拨号,而不是通过 SIP。
Syntax:
Local/extension@context[/n]
Local/extension@context[/nj] (starting with Asterisk 1.6, backport available for 1.4)