SOLVED Custom default settings per domain

Status
Not open for further replies.

czbg

Member
Sep 27, 2018
33
1
8
Hi all,

customer have a request, that all the call recordings should be sent to some email address. I've tried the modified email.lua with hardcoded addresses and it works ok, but I would like to do that properly.

I started by adding two settings to the "Domains" - category "Recordings" - settings email_recordings(true/false boolean) and email_recordings_to (email address text).
I wanted to check if this variables are loaded and now I'm stuck. I am not sure if I should see them in dialplan or what?

Please someone give me some pointers where to look or how this default settings should work.

Thanks..
 

czbg

Member
Sep 27, 2018
33
1
8
Hm, looks like I posted this in the wrong category.. Sorry all. Can I move it somehow?
 

czbg

Member
Sep 27, 2018
33
1
8
This is how I've managed to get this working:
Dialplan -> Dialplan Manager -> user_record

At the end, I inserted:
Code:
    <condition field="${record_session}" expression="^true$">
        <action application="set" data="email_recordings_to=example@example.com"/>
        <action application="set" data="email_recordings_subject=Recording of a call from ${caller_id_number} to ${destination_number}"/>
        <action application="set" data="email_recordings_delete_after=false"/>
        <action application="export" data="record_post_process_exec_app=lua:email_recordings.lua ${record_path}/${record_name}"/>
    </condition>

email_recordings.lua is a modified email.lua, that I found in scripts directory. Modifications:
Code:
@@ -38,15 +38,26 @@
 --Example
        --luarun email.lua to@domain.com from@domain.com 'headers' 'subject' 'body'

+local Settings = require "resources.functions.lazy_settings"
+local Database = require "resources.functions.database"
+local db = dbh or Database.new('system')
+local settings = Settings.new(db, domain_name, domain_uuid)
+
 --get the argv values
        script_name = argv[0];
-       to = argv[1];
-       from = argv[2];
-       headers = argv[3];
-       subject = argv[4];
-       body = argv[5];
-       file = argv[6];
-       delete = argv[7];
+       to = session:getVariable("email_recordings_to");
+       from = settings:get('email', 'smtp_from_name', 'text')
+       headers = "";
+       subject = session:getVariable("email_recordings_subject");
+       body = "";
+       file = argv[1];
+       delete = session:getVariable("email_recordings_delete_after");
+       if delete == nil then
+               delete = "false";
+       end
        --convert_cmd = argv[8];
        --convert_ext = argv[9];
 
  • Like
Reactions: JamesBorne

noci

New Member
Aug 9, 2019
7
2
3
NL
Why not:
Add these to the last user_record rule block (9):
XML:
        <action application="set" data="email_recordings_to=${recordings_email}" inline="true"/>
        <action application="set" data="email_recordings_subject=Recording of a call from ${caller_id_number} to ${destination_number}" inline="true"/>
        <action application="set" data="email_recordings_delete_after=${recordings_email_delete}" inline="true"/>
        <action application="export" data="record_post_process_exec_app=lua:email_recordings.lua ${record_path}/${record_name}" inline="true"/>

Or add a new block (#10) with conditions if recordings_email holds a email address
XML:
    <condition field="${record_session}" expression="^true$" break="never"/>
    <condition field="${recordings_email}" expression="^[0-9a-zA-Z_.-]+@" break="never">
        <action application="set" data="email_recordings_to=${recordings_email}" inline="true"/>
        <action application="set" data="email_recordings_subject=Recording of a call from ${caller_id_number} to ${destination_number}" inline="true"/>
        <action application="set" data="email_recordings_delete_after=${recordings_email_delete}" inline="true"/>
        <action application="export" data="record_post_process_exec_app=lua:email_recordings.lua ${record_path}/${record_name}" inline="true"/>
    </condition>


And then add default variables: recordings_email & recordings_email_delete with email address & true/false?
 
Last edited:

czbg

Member
Sep 27, 2018
33
1
8
Hi noci, thanks for your suggestions. For now everything is working fine, so I will not play with it anymore if not needed. When some problem arises I will surely try your suggestion.

Just fyi, I think "inline=true" has no meaning in export application?
 

Robert Birch

Member
Mar 16, 2017
111
5
18
53
Hey Everyone,
I was looking at this and have it somewhat working.

If an extension places a call, I get the recording emailed. If it is an incoming call, I don't get the recording. I can see the recording in CDR, but it seems from the logs that the script isn't called from an incoming call.

I tried the above both ways, adding the lines to the last user_record block and as it's own block. Works either way for outgoing, nothing for incoming.

I do have the extension set to record all.

Is there a different part of the dialplan to modify for internal calls?

Thanks,
Shredder
 

Robert Birch

Member
Mar 16, 2017
111
5
18
53
OK. I think I got a little further with this. If I set the destination to go straight to an extension, it works.

What I need to do, is have the call go to a RingGroup first. Seems if I it goes to a RingGroup first, I don't get the email.

Any ideas?

Thanks,
Shredder
 

czbg

Member
Sep 27, 2018
33
1
8
Hi Robert,

check if you have call_direction correctly set by dialplan. I vaguely remember that I had a problem like this. I posted about it here.

BR
 

Robert Birch

Member
Mar 16, 2017
111
5
18
53
If I look at the CDR for a call, call_direction is set to inbound in all spots usinf the default call_direction dialplan.
I think the issue is the RingGroup, but I am not knowledgeable enough to know why it is stoppping it.

I do see in the CDR for calls that go to a RingGroup first, the Extension field (first one after the arrow icon) is blank. If I make the call go directly to an extension, the extension number is there.

Thanks,
 
Status
Not open for further replies.