Search code examples
audionode-redrecordingvonage

How to list call recordings in Nexmo?


I'm working on a voice assistant with Nexmo. I use Node-RED to build the NCCO object including a record node.

In the provided tutorials by Nexmo, e.g. Build Your Own Voicemail With Node-RED and the Nexmo Voice API the directly download the recording to the local machine.

In my case, don't want to immediately download the audio file via node-red but let Nexmo store my audios and download them all together later through e.g. a Python script.

In the docs it says that "NOTE: After your recording is complete, it is stored by Nexmo for 30 days before being automatically deleted".

Unfortunately, I can't find any reference about where the audios are stored in my Nexmo account and how to list all recordings/recording urls of a Nexmo application.

Thank you for any help.

Nina


Solution

  • Currently there’s no way to get the recordings as a list from Nexmo.

    What you could do instead is, capture the API response from the recording webhook and log it.
    Then later on when you’re ready to download them, read it back to a get recording node.

    If you connect a debug node into the /recording webhook, you can see the structure of the message object.

    payload: object
       start_time: "2020-03-04T13:06:40Z"
       recording_url: "https://api.nexmo.com/v1/files/516f74a8-abcd-4270-b553-2582650a2e5a"
       size: 26478
       recording_uuid: "dbd3cb68-0a3a-4c89-bc2d-7c38abd2c497"
       end_time: "2020-03-04T13:06:47Z"
       conversation_uuid: "CON-93ef5eef-gg92-49ae-9e01-f3c782390dd9"
       timestamp: "2020-03-04T13:06:47.733Z"
    

    You’ll need the recording_url to download a recording, but it’s good to keep the conversation_uuid handy, as you can lookup the FROM and TO numbers based on this.

    I'm leaving a possible solution with Google Sheets below, as a replacement for the /recording webhook. Import it from clipboard into your editor and see the comment node for instructions :)

    [{"id":"9198a326.cfb3e","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"49dc7444.625ff4","type":"http in","z":"9198a326.cfb3e","name":"","url":"/record","method":"post","upload":false,"swaggerDoc":"","x":210,"y":380,"wires":[["21594561.f44c1a","47021216.a25afc","dc814f00.17fa7"]]},{"id":"47021216.a25afc","type":"http response","z":"9198a326.cfb3e","name":"","statusCode":"","headers":{},"x":610,"y":380,"wires":[]},{"id":"5371302c.ee3688","type":"getrecording","z":"9198a326.cfb3e","creds":"10de89c6.d1db3e","filename":"recordings/{{msg.payload.from}}_{{msg.payload.timestamp}}.mp3","x":1260,"y":580,"wires":[["6d03a7ed.2a6d7","38dd6acf.b46cae"]]},{"id":"21594561.f44c1a","type":"debug","z":"9198a326.cfb3e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":450,"y":320,"wires":[]},{"id":"bcb08110.c2f7c","type":"e-mail","z":"9198a326.cfb3e","server":"smtp.gmail.com","port":"465","secure":true,"tls":true,"name":"","dname":"","x":1690,"y":580,"wires":[]},{"id":"6d03a7ed.2a6d7","type":"debug","z":"9198a326.cfb3e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1490,"y":500,"wires":[]},{"id":"38dd6acf.b46cae","type":"change","z":"9198a326.cfb3e","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"'Voicemail from ' & msg.req.query.from","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1500,"y":580,"wires":[["bcb08110.c2f7c"]]},{"id":"c8fadcb1.13aca","type":"inject","z":"9198a326.cfb3e","name":"Download/Send recordings in email","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":280,"y":580,"wires":[["af254a75.791888"]]},{"id":"f9706ea5.ea66","type":"change","z":"9198a326.cfb3e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t    \"start_time\": (msg.payload)[0],\t    \"recording_url\": (msg.payload)[1],\t    \"size\": (msg.payload)[2],\t    \"recording_uuid\": (msg.payload)[3],\t    \"end_time\": (msg.payload)[4],\t    \"conversation_uuid\": (msg.payload)[5],\t    \"timestamp\": (msg.payload)[6],\t    \"from\": (msg.payload)[7]\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1060,"y":580,"wires":[["5371302c.ee3688"]]},{"id":"9f017b25.db6fe8","type":"debug","z":"9198a326.cfb3e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":970,"y":440,"wires":[]},{"id":"dc814f00.17fa7","type":"change","z":"9198a326.cfb3e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[payload.start_time, payload.recording_url, payload.size, payload.recording_uuid, payload.end_time, payload.conversation_uuid, payload.timestamp, req.query.from]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":440,"wires":[["c8118876.f668e"]]},{"id":"521189f7.2f6d8","type":"debug","z":"9198a326.cfb3e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":830,"y":760,"wires":[]},{"id":"deba2a63.a4f4d","type":"split","z":"9198a326.cfb3e","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":830,"y":580,"wires":[["f9706ea5.ea66"]]},{"id":"c8118876.f668e","type":"GSheet","z":"9198a326.cfb3e","creds":"90e07aa9.34a6","method":"append","action":"","sheet":"1mmXhj40aeSooxmtku3ma4auLyrHhJO8xCSQsklZ1_BU","cells":"Sheet4!A1","name":"","x":730,"y":440,"wires":[["9f017b25.db6fe8"]]},{"id":"af254a75.791888","type":"GSheet","z":"9198a326.cfb3e","creds":"bd7b95fd.c3dee8","method":"get","action":"","sheet":"1mmXhj40aeSooxmtku3ma4auLyrHhJO8xCSQsklZ1_BU","cells":"Sheet4!A:H","name":"","x":610,"y":580,"wires":[["521189f7.2f6d8","deba2a63.a4f4d"]]},{"id":"335f8e96.7242ba","type":"comment","z":"9198a326.cfb3e","name":"📖 Instructions","info":"1. Install `node-red-contrib-google-sheets` package and restart Node-RED.\n2. Add _creds_, _SpreadsheetID_ and _Cells_ in the **GSheet** nodes \n3. Add your Nexmo credentials in the **Get Recording** node\n4. Configure **email** node or add download functionality","x":220,"y":180,"wires":[]},{"id":"10de89c6.d1db3e","type":"nexmovoiceapp","z":"","name":"New Voice App"},{"id":"90e07aa9.34a6","type":"gauth","z":"9198a326.cfb3e"}]