SOLVED Voicemail Download Link

Status
Not open for further replies.

Sunny Gosain

New Member
Oct 27, 2020
11
0
1
52
SYSTEM VERSION:V4.4.3 Debian 9.9

This is a beginner's question. We have currently configured Voicemail and are receiving the voicemails as an email attachment. Is there a way to also publicly access the voicemail audio files ? i.e. would we need to reconfigure nginx to publicly access/download the files located at /var/lib/freeswitch/storage/voicemail/default/<domain>/<extension>/msg_xxxx.wav

The reason for doing this is so we can paste these links on the contact record in our CRM.

I understand that we could very well change the voicemail_id setting in the app
/app/voicemails/voicemail_edit.php?id=xxxx to send the link via email (in lieu of the attachment) but is there a way to do both (i.e. get the attachment and still access the file via a public link?)


In summary I'm wondering if it possible to get a public link to the file such as:
/app/voicemails/voicemail_messages.php?action=download&voicemail_uuid=xxxx&uuid=xxxxx
 

ad5ou

Active Member
Jun 12, 2018
884
195
43
I'm not sure if 4.4 matches 100% with the scripts in 4.5 but yes it is possible to have both with a few changes to the "send_email" script.

In /usr/share/freeswitch/scripts/app/voicemail/resources/functions/send_email.lua (or your scripts directory) Find the section "--prepare the body"
Look for the section similar to below:
Code:
if (voicemail_file == "attach") then
body = body:gsub("${message}", text['label-attached']);
elseif (voicemail_file == "link") then
body = body:gsub("${message}", "<a href='"..link_address.."/app/voicemails/voicemail_messages.php?action=download&id="..id.."&voicemail_uuid="..db_voicemail_uuid.."&uuid="..uuid.."&t=bin'>"..text['label-download'].."</a>");
else
body = body:gsub("${message}", "<a href='"..link_address.."/app/voicemails/voicemail_messages.php?action=autoplay&id="..db_voicemail_uuid.."&uuid="..uuid.."'>"..text['label-listen'].."</a>");
end
edit the if/elseif/else statements as needed to provide the link you desire. For example if setting is "attach" the below code will now attach the message and provide a download link.
Code:
if (voicemail_file == "attach") then
body = body:gsub("${message}", text['label-attached']);
body = body:gsub("${message}", "<a href='"..link_address.."/app/voicemails/voicemail_messages.php?action=download&id="..id.."&voicemail_uuid="..db_voicemail_uuid.."&uuid="..uuid.."&t=bin'>"..text['label-download'].."</a>");
elseif (voicemail_file == "link") then
body = body:gsub("${message}", "<a href='"..link_address.."/app/voicemails/voicemail_messages.php?action=download&id="..id.."&voicemail_uuid="..db_voicemail_uuid.."&uuid="..uuid.."&t=bin'>"..text['label-download'].."</a>");
else
body = body:gsub("${message}", "<a href='"..link_address.."/app/voicemails/voicemail_messages.php?action=autoplay&id="..db_voicemail_uuid.."&uuid="..uuid.."'>"..text['label-listen'].."</a>");
end

Disclaimer: this will change the actions system wide, it may cause conflicts for fusionpbx upgrades,

An alternative way would be to edit other pages and this script to allow for a "attach with download link" setting.
 

TC Dan

New Member
Sep 6, 2018
8
1
3
53
Do you mean "public" as in "accessible to anybody on the internet"?
That seems like a bad idea (and will be illegal in lots of jurisdictions)..
 

Sunny Gosain

New Member
Oct 27, 2020
11
0
1
52
@ad5ou: Thanks, I'll give it a shot.
@TC Dan: 'Public' as in accessible by the user (extension) for whom the voicemail is intended without the user having to explicitly loginto FusionPBX (I guess that is the quandary). The use case is for the CRM agents (the user with the extension) that receive voicemails from their clients, now, rather than send them emails with attachments (which they then have to log into their email and check), the objective is to link the the voicemail in the CRM's contact record so that the agents does not have to switch back/forth between the CRM and the Email. Only The user-agent that has access to the contact record will be able to 'listen' to the voicemail from the link(In this case the authetication is implied by the access record in the CRM). Perhaps there are legal ramifications that I am not aware of. We will research the best practice on this further but it seems the link generated by FusionPBX would obviously require the agent to be logged into FusionPBX to hear the audio.

 

ad5ou

Active Member
Jun 12, 2018
884
195
43
The link generated doesn't require a login.
It isn't super secure, but since the link includes a UUID, it would be difficult to stumble onto the file
 

TC Dan

New Member
Sep 6, 2018
8
1
3
53
I get the usecase now, thanks for the explanation!
There are a couple of thoughts plopping up in my mind immediately on how this could go wrong, but I guess that falls in the category of "everyone choose their own level of paranoia"..
 

Sunny Gosain

New Member
Oct 27, 2020
11
0
1
52
There is a probable bug (or maybe its my misunderstanding or misconfiguration on our end) in version 4.4.3 that in a multi-tenant (multi-domain) environment the link that is generated for the domain is incorrect because it starts with the domain name which the DNS cannot resolve. e.g. if FusionPBX is hosted on host.com and it has a domain namely domain.com then the link will generate correctly for a voicemail-message in the primary domain (e.g. host.com) but not for a voicemail-message for an extension defined in a tenant's domain (e.g. domain.com) i.e. the generated link below will not resolve:

https://domain.com/app/voicemails/voicemail_messages.php?action=download&type=vm&t=bin&id=<extension>&voicemail_uuid=<vmail_uuid>&uuid=<uuid>&src=email

Closing this issue, as the original question has been answered by @ad5ou (Thanks!) that by changing the script its possible to have both the link and the attachment in the Email. We have decided to just work with the Email attachments.
 

ad5ou

Active Member
Jun 12, 2018
884
195
43
If you are editing the script, it wouldn’t take much more to tweak the link provided.

4.4 isn’t getting much attention anymore so if it is really a bug, it probably won’t be fixed in that branch.
 
Status
Not open for further replies.