KevinBonnoron / node-red-contrib-freebox

4 stars 4 forks source link

"Retrieve a voicemail" does not work #43

Closed MuadDibVV closed 1 year ago

MuadDibVV commented 1 year ago

Hello,

Thank you for your work ! I need to retrieve voicemail audio file with the API "Retrieve a voicemail" GET /api/v10/call/voicemail/{id}/audio_file But the result is undefined (of course I replaced {id} by a real voicemail id) image

Is it possible to make this call successful ? Regards

KevinBonnoron commented 1 year ago

Hello,

Do you have any error log? Could you also provide the flow you are using please?

Thanks

MuadDibVV commented 1 year ago

Hello,

Thank you for your answer. There is no error.

Here is my flow :

[ { "id": "26435cba881c83cd", "type": "inject", "z": "1d16ac503ebec144", "name": "", "props": [ { "p": "url", "v": "/call/voicemail/", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "x": 1310, "y": 600, "wires": [ [ "e8ff69aa1a7258e2" ] ] }, { "id": "e8ff69aa1a7258e2", "type": "api", "z": "1d16ac503ebec144", "name": "voicemail list", "url": "/call/voicemail/", "server": "fbbfb4a84dd591b5", "x": 1470, "y": 600, "wires": [ [ "8d5cd2175aec44c8" ] ] }, { "id": "8d5cd2175aec44c8", "type": "switch", "z": "1d16ac503ebec144", "name": "Si message", "property": "payload.length", "propertyType": "msg", "rules": [ { "t": "gt", "v": "0", "vt": "num" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 1650, "y": 600, "wires": [ [ "977f3f5dfb0674fe" ] ] }, { "id": "977f3f5dfb0674fe", "type": "change", "z": "1d16ac503ebec144", "name": "", "rules": [ { "t": "set", "p": "url", "pt": "msg", "to": "\"/call/voicemail/\" & payload[0].id & \"/audio_file\"", "tot": "jsonata" }, { "t": "set", "p": "method", "pt": "msg", "to": "GET", "tot": "str" }, { "t": "delete", "p": "payload", "pt": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1500, "y": 680, "wires": [ [ "b995f47a08dd15e2", "8166c328345cdc98" ] ] }, { "id": "b995f47a08dd15e2", "type": "api", "z": "1d16ac503ebec144", "name": "voice msg", "url": "", "server": "fbbfb4a84dd591b5", "x": 1660, "y": 680, "wires": [ [ "8166c328345cdc98", "b4b5bb386d87675f" ] ] }, { "id": "8166c328345cdc98", "type": "debug", "z": "1d16ac503ebec144", "name": "debug 2", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 1800, "y": 840, "wires": [] }, { "id": "fbbfb4a84dd591b5", "type": "freebox-server", "host": "https://mafreebox.freebox.fr", "port": "443" } ]

And here the result

image

Regards

KevinBonnoron commented 1 year ago

Hello.

I took a look at your bug and the endpoint you are trying to call is retuning a file in the http response. This library was intended to support json response only so that's the reason why you are getting an undefined payload.

Before doing anything what data type do you expect to get? I can try to put the binary into the payload property but i will not be able to test it since i don't have any voice call.

MuadDibVV commented 1 year ago

Hello, Thank you for your answer. Here is a part of the documentation

Retrieve a voicemail
GET /api/v10/call/voicemail/{id}/audio_file
Download voicemail message in WAV format.

Example request:

GET /api/v10/call/voicemail/20221215_154135_r0334371508.au/audio_file HTTP/1.1
Host: mafreebox.freebox.fr
Example response:

HTTP/1.1 200 OK
Content-Type: audio/wav; charset=utf-8
Content-Length: 60218
Content-Disposition: inline; filename="20221215_154135_r0334371508.wav"

/* binary data */

Regards

KevinBonnoron commented 1 year ago

Yes i saw the documentation. I was asking you what data type were you expecting? I made a version this morning (15.0.0-0), but there seems to be an issue with npm right now. So as soon they fixed it i will update the version on NodeRed. Will tell you when it's ok

KevinBonnoron commented 1 year ago

OK there is now version 0.0.15 which should include some code to handle your case. Could you tell me if it is working?

MuadDibVV commented 1 year ago

Thank you There is no regression, but the result for voicemail is still ko (Not undefined but there is no result, the flow is stopped) Perhaps it is possible to retrieve the "statusText" result of axios to get an error message ? Regards

MuadDibVV commented 1 year ago

I think we have to change the property of axios responseType during the call (// les possibilités sont : 'arraybuffer', 'document', 'json' (par défaut), 'text', 'stream')

KevinBonnoron commented 1 year ago

Sorry i have been busy lately. Yes maybe change the responseType will work. Will try to make a version this week

KevinBonnoron commented 1 year ago

OK i released the version 0.0.16 which handle a new input parameter "responseType". In this case we can test every possible values. So could you add an input to the api node with a parameter named "responseType" with a value of "arraybuffer" and tell me if this solve your issue.

MuadDibVV commented 1 year ago

Thank you @KevinBonnoron. Now I have an answer with the arraybuffer or stream responseType image I don't succeed to create correct wave file with this buffer for the moment but I progress !

KevinBonnoron commented 1 year ago

What do you exactly want to do with the file in your flow?

MuadDibVV commented 1 year ago

I retrieve the message via Freebox API, convert it in mp3 and read it on my Nest hub.

When I write the wave file in utf8, it is not readable When I write the wave file in ISO-8859-5 the wave is noisy So I am looking for the best way to write the wave file.