2017-08-26 33 views
0

我已經開發了一個網絡,將兩個人連接到本教程後面的電話: https://www.twilio.com/docs/tutorials/click-to-call-node-express 並且一切工作正常。Twilio點擊通話並收集數字

現在我需要收集被調用者的一位數字以執行一個命令。

閱讀Twilio文檔,似乎我無法使用收集直到Dial動詞結束,但這樣呼叫關閉,被叫方無法對數字進行任何處理。

我想這沒有成功,撥號工作正常,但永遠不會執行數字回調:

twimlResponse.say(
    'Please wait for the other person to join the call' 
); 

    twimlResponse.dial({ 
    timeLimit: 30 
    }) 
    twimlResponse.dial(to_number) 

    const gather = twimlResponse.gather({ 
    input: 'dtmf', 
    timeout: 30, 
    numDigits: 1, 
    action: url // the url is the callback that should handle the digit entered 
    }); 

它是Twilio的限制?任何解決方法或替代呼叫策略?

+0

嘿法布里奇奧,你需要進行收集被叫方的一端連接之前,或在談話中? – philnash

+0

我需要在通話結束時執行聚會,作爲被叫方在與另一方通話後應執行的最終動作。 –

回答

1

我相信你需要發送一個url和你撥打的number,然後讓這個URL與你要驅動與被調用者進行交互的TwiML響應。從https://www.twilio.com/docs/api/twiml/number

「網址」屬性允許你指定一個TwiML文件 將被叫方的最終運行,她回答後一個網址,但連接各方 之前。您可以使用此TwiML私密播放或向被叫方說出信息,或提供使用<Gather><Hangup>拒絕 電話的機會。

因此,像這樣:

const dial = twimlResponse.dial({ 
    timeLimit: 30 
}); 
dial.number({ 
    url: urlToGather // respond to this URL with your <Gather> TwiML 
}, to_number); 
+0

謝謝smarx,該解決方案不適合我的需求,因爲我需要在通話結束時收集數字。 –

+0

我不確定這可以做到。 [動作屬性](https://www.twilio.com/docs/api/twiml/dial#attributes-action)似乎最有前途,但這似乎特定於「撥打方」(被叫方)掛斷電話。 – smarx