Fusionpbx voicemail after IVR doesn't work
Here's a tough one. You have set up a voicemail in Fusionpbx with redirect to some email you tested it and of course it works. Now you use the same voicemail but after an IVR and find yourself with no email of the voicemail.
At this point I assume you looked in freeswitch and found something like this
2019-09-26 17:00:07.774716 [ERR] mod_lua.cpp:203 ...scripts/app/voicemail/resources/functions/send_email.lua:166: attempt to index global 'subject' (a nil value)
stack traceback:
...scripts/app/voicemail/resources/functions/send_email.lua:166: in function 'send_email'
/usr/share/freeswitch/scripts/app/voicemail/index.lua:588: in main chunk
/usr/share/freeswitch/scripts/app.lua:48: in main chunk
If you look at the code of that lua file where the issue occurs you will see that it tries to assemble the subject line of the email but fails since subject
is actually nil
but how can that be? Why does it work when you call the voicemail directly?
subject = subject:gsub("${caller_id_name}", caller_id_name);
Doing some further digging and enabling debug SQL output (edit /etc/fusionpbx/config.lua
and set debug.sql = true
) you will find this select statement:
2019-09-26 19:15:13.914708 [NOTICE] switch_cpp.cpp:1365 [voicemail] SQL: SELECT * FROM v_email_templates WHERE (domain_uuid = :domain_uuid or domain_uuid is null) AND template_language = :template_language AND template_category = 'voicemail' AND template_subcategory = 'default' AND template_enabled = 'true' ORDER BY domain_uuid DESC ; params:{"template_language":"de-at-de","domain_uuid":"xxxx"}
Notice the "template_language":"de-at-de"
? well how did that get in there? Your system uses german as main but sure it does not use de-at-de. Let's see the lua code for this again: template_language = default_language.."-"..default_dialect
it takes the default_language and combines it with the default_dialect. Nothing wrong with that since the fusionpbx settings have de
as language and de
as dialect.
The issue is that the language at this point is NOT taken from the fusionpbx variables but from the IVR language but combines it with the default dialect from the variables.
Setting this to en
(which actually was the initial setting) won't help either because in combination with the default dialect it would result in en-de
which also does not work.
You now have two options:
- Create an email template
en-de
orde-at-de
to make it happy and not fail finding a template. - Change the IVR language to
de
which results inde-de
which in turn will enable the voicemail lua to find an email template.