Search code examples
javascriptnode.jsplivo

Plivo play a message if voice mail is detected otherwise connect to human


Using Node.js I am making an outbound call using Plivo. What I am stuck on is, how would I detect if the call is answered by a human or machine, and play a message if a machine answered, or connect the call to a human if a human answered? I have tried placing a transfer_call command in the machine_detection_url but the call still continues on the answer_url instead of switching to the xml provided by the url in the transfer_call.


Solution

  • Plivo Sales Engineer here.

    When making an outbound call api request, using machine_detection_url would detect machine asynchronously, i.e, once the call is answered, the answer_url would get executed and machine detection occurs in parallel. The answer URL could contain a Speak or a Play till the Machine detection ends. Depending on the results, "Machine" parameter is posted to the machine_detection_url with value "True" or "False". In the machine_detection_url, you should use transfer api to transfer the call to a Voicemail if Machine=True. If Machine=False, transfer the call to a Dial XML or continue executing the answer url.

    Another method to do this, is to use machine detection synchronously, without using machine_detection_url. The results of machine detection will be posted to the answer url and you can return appropriate XML.