Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - asymetrixs

Pages: [1] 2 3 4
1
Other Yate server issues / Re: Javascript http request
« on: April 03, 2018, 01:25:48 PM »
The javascript interpreter is custom build, so it lacks lots of functionality that e.g. V8 would offer, because it was specifically for use with yate.

2
In my example I am not using javascript.conf routing= to register the routing script. I just have a line at the bottom after [scripts] like
Code: [Select]
myivr=ivr.js and this ivr.js script is listening for the engine.timer message and initiates a call (if the database returns specific data)
So calls are only initiated if the database "says so".

So, what I basically want is to trigger yate to initiate an outgoing call that is then internally connected to an IVR, preferably written in Javascript.

As far as I understood:
- each JS script is creating a new instance when called, not only routing=<script.js> will result in 20 instances for 20 routing messages but also the custom defined scripts at the bottom will be called in an instance each time they are fired.
- my engine.timer fires up new instances of the script every time it elapses
- within this script I can use the predefined functions like onAnswered, onDisconnected, so I don't need to register my own handlers

How can I specify if my script runs per channel or only once globally?

3
ok, so I have a JS script now that listens for engine.timer and creates a call everytime engine.timer fires (basically every second)

Code: [Select]
           
function onTimer(msg)
{
    // Get DB Object
    var m = new Message("database");
    // Specify connection to use
    m.account = "ivrcon";
    // Define Query
    m.query = "SELECT OK, number, call FROM get_next_call();";

    // Run the Query
    if (m.dispatch())
    {
        if (m.rows > 0)
        {
            Engine.debug(Engine.DebugInfo, "CREATING CALL.EXECUTE");
           
            var executeMsg = new Message("call.execute", msg);
            executeMsg.callto = "dumb/";
            executeMsg.target = "123456";
            executeMsg.caller = "test";
            executeMsg.callername = "test";

            Engine.debug(Engine.DebugInfo, "DISPATCHING CALL.EXECUTE");

            if(executeMsg.dispatch())
            {
                Engine.debug(Engine.DebugInfo, "PEER ID: " + executeMsg.peerid);

                Message.install(onCallAnswered,"call.answered",80, "id", executeMsg.peerid);
                Message.install(onChanNotify,"chan.notify",80, "id", executeMsg.id);
                Message.install(onChanDtmf,"chan.dtmf",80, "id", executeMsg.peerid);
               
                // one of both parties can hangup
                Message.install(onChanDisconnected,"chan.disconnected",100, "id", executeMsg.peerid);
                Message.install(onChanDisconnected,"chan.disconnected",100, "id", executeMsg.id);
            }
        }
    }
    else
    {
        Engine.output("Query failed");
    }
   
    return true;
}


function onCallAnswered(msg)
{
    Engine.debug(Engine.DebugInfo, "Chan.Answered ID: " + msg.id);
    Engine.debug(Engine.DebugInfo, "Chan.Answered PeerID: " + msg.peerid);

    var chanAttachMsg = new Message("chan.masquerade");
    chanAttachMsg.message = "chan.attach";
    chanAttachMsg.id = msg.peerid;
    chanAttachMsg.source = "wave/play//usr/share/yate/sounds/prompt_for_destination.alaw";
    chanAttachMsg.notify = msg.id;
    chanAttachMsg.dispatch();

    wait_for_notify = true;
    msg.handled = true;

    return true;
}

Engine.debugName("ivr-handler");
Message.trackName("ivr-handler");
Engine.debugEnabled(true);

// Message handler
Message.install(onTimer,"engine.timer",80);

So, I wonder if I need to install the handler with the "id" parameter and the filter for the message IDs. Anyway, like this, many calls will be created from yate in parallel, so there will be lots of chan.dtmf, chan.notify, chan.disconnected etc. messages. This leads me to the following question:

1. When engine.timer fires and the handler will call "onTimer", is this a new script instance every time or will the same script be used?
2. Are the executed calls and their messages always received by the same instance (does each call have it's own instance (like question above)) and can I use "instance-only visible" variables to store states and additional information for processing? Or do I always need to track the "id" parameter in the handlers to know to which call a message belongs? Or is the same instance always receiving the message because of the installed filter on message.id?


Also, as I understand, as this whole script is not called in the normal routing process, functions like Channel.callJust/callTo etc. are not available.

Thank you.

4
ok, found the answer here https://forum.yate.ro/index.php?topic=382.0

However, http://docs.yate.ro/wiki/How_to_do_routing_using_javascript says, that when a call is incoming, a new script instance is launched and the incoming call is connected to this instance (that is dedicated to the incoming call leg)

What if I create an outgoing call like this:

Code: [Select]
var executeMsg = new Message("call.execute", msg);
executeMsg.callto = "dumb/";
executeMsg.target = "123456";
executeMsg.caller = "test";
executeMsg.callername = "test";
executeMsg.dispatch();

I can then register handler, e.g.
Code: [Select]
Message.install(onChanDtmf,"chan.dtmf",80, "id", executeMsg.peerid);but do I need the 3rd and 4th parameter or can I go with
Code: [Select]
Message.install(onChanDtmf,"chan.dtmf",80);, too?

What is the difference, is the first method a way to route the messages to the correct script instance whereas the 2nd (without the last parameters) routes messages to any instance?



5
Can you please provide a small javascript example, that kicks in after my call.execute.
My call.execute calls my SIP phone and plays the wave. Then after that the call is terminated.
So, what JS code can handle the chan.disconnected message and connect it to a new voice file? I tried for several hours and I cannot make it....documentation is very limited.

6
Hi,

I want yate to make an outgoing call to a party and once this party answers the call, it should be connected to an internal javascript that runs an IVR.

I know that via javascript routing I can connect an incoming call to a javascript-ivr, but in this scenario it is an outgoing call.

What I have so far is a javascript registered in javascript.conf
Code: [Select]
jstrigger=trigger.js
with the following content, which causes Yate to create an outgoing call (in this case to my SIP phone which address is in m.getResult(0,1)).
Now after establishing this call I want to connect it to a javascript that plays a sound file and can handle DTMF. The problem right now is connecting it to this file. Once it is connected, I guess I can simply install handlers for chan.dtmf and receive the buttons pressed.

Code: [Select]
function onTimer(msg)
{
    //Engine.debug(Engine.DebugInfo,"Got Engine.Timer");

    // Get DB Object
    var m = new Message("database");
    // Specify connection to use
    m.account = "ivrcon";
    // Define Query
    m.query = "SELECT OK, number, call FROM get_next_call();";
    // Run the Query
    if (m.dispatch())
    {
        if (m.rows > 0)
        {
            Engine.debug(Engine.DebugInfo, "Got " + m.rows + " records of " + m.columns + " fields");

            var executeMsg = new Message("call.execute", msg);
    executeMsg.id = Math.random(10000,10000000);
            //executeMsg.callto = "wave/play//usr/share/yate/sounds/prompt_for_destination.alaw";
            executeMsg.callto = "wave/play/-"; // silence
            executeMsg.called = m.getResult(0,1);
            executeMsg.caller = "Hans";
            executeMsg.callername = "Hans";
            executeMsg.dispatch();
        }
    }
    else
    {
        Engine.output("Query failed");
    }

    return false;
}

Engine.debugName("ivr-call-trigger");
Message.trackName("ivr-call-trigger");
Engine.debugEnabled(true);
Message.install(onTimer,"engine.timer",80);

Is this even possible or do I need to connect it via
Code: [Select]
external to a PHP script?

7
Linux / Re: upgrade yate
« on: February 05, 2017, 06:43:50 AM »
You can upgrade. Check the changelog to see what has changed, but normally it sould be possible without any implications.

http://yate.null.ro/websvn/log.php?repname=yate&path=&rev=0&isdir=1

8
You receive 0-N call.cdr messages, because yate emits a new message every  time something in the call state has changed.
Therefore you should register a handler for call.cdr, but check the field 'operation' which is "initialize" (once), "update" (several times) or "finalize" (once the call has ended).
When receiving the operation=finalize message, you can do your tale updates.
see http://docs.yate.ro/wiki/CDR_Build_Module

Moreover, in case you use connection pooling, the cdr initialize/update/finalize messages do NOT come in order. There might be a finalize message appearing before an update message or even before the 'initialize' message. That is because yate queues the messages before sending them to the sql server but sends them in the best order regarding performance.
So in your SQL-Query you should make sure only to update the database records when you receive the 'finalize' message and if the call already has ended (record if ended=true in database and check on each initialize or update if it already ended) do not touch it anymore.
See http://docs.yate.ro/wiki/Register_Database_Schema bottom example implementation of a cdr initialize/update/finalize sql procedure.

9
I dont understand what you are trying to do.

Do you want the script to update ALL cdrs or just the one for the current channel the script is working on?
If you want to update a cdr record only if the call has finished, then wait until the cdr.finalize message is sent. If you receive this, you can flag the call as ended and perform post operations (run an sql or something like that) on the database record.

10
SIP to H.323 proxy / Re: custom H323 header
« on: February 05, 2017, 06:28:04 AM »
How did you try it?

Sending a custom SIP header is done via 'osip_' prefix. E.g. if you want to send a field called 'userdata', then in sip it would be osip_userdata=theactualdata.
I am not sure for h323, but you can look into the yate source of the h323 module (maybe this: https://github.com/vir/yate/blob/master/modules/h323chan.cpp) or give oh323_userdata=<...> a try.

11
Yate based projects / Re: BILLING FOR EXISTING YATE SETUP
« on: February 05, 2017, 06:24:23 AM »
A quick google search reveals:

collecting cdr information:
http://docs.yate.ro/wiki/Call_Detail_Records_Modules
http://docs.yate.ro/wiki/PostgreSQL
http://old.yate.ro/pmwiki/index.php?n=Main.CollectingBillingInformation
http://docs.yate.ro/wiki/Register_Database_Schema (code at the bottom)

billing:
http://docs.yate.ro/wiki/How_to_route_and_bill_from_a_database

There is no billing module that does all the work.
You need to do the routing and configure yate to record the cdrs (see above). Based on the cdr information you can do the billing, but you need to develope your own software/scripts to do the calculations.

12
Yate users hangout place / Re: Call logs empty?
« on: February 05, 2017, 06:20:06 AM »
enable logging and logging level in the configs or just start yate with parameter '-v'. the more 'v's you add, the more detailed the log will become, e.g. yate -vvvvvvvvvvvvvvv

13
Yate users hangout place / Re: YATE DOCUMENTATION
« on: February 05, 2017, 06:18:46 AM »
Always depends on what you are doing.
There are plenty of information in the news group (just google) and you can ask here in the forum or in IRC (freenode, #yate).

Moreover yate ships with several scripts (php, python, etc.) and freesentral, you can look into the source and learn from it or adapt the scripts to your needs.

14
Yate users hangout place / Re: Play the file after the call
« on: June 04, 2015, 04:32:21 AM »
Thank you very much for your help.
Figured out how it should work.

parti3an, please provide your solution here so that others can benefit as well, thanks.

15
YateBTS / Re: Error !! Could not open for writing on NIB (Regexp)
« on: March 22, 2015, 04:24:42 AM »

You can run as root:
chmod a+rw /usr/local/etc/yate/


No, don't do that. If you need the yate-user and the apache-user to access this file, create a new group e.g. apacheyate, put both users in that group and give that group permission to change the file. if you use a+rw then everybody can modify the file and you don't want that e.g. if you have several users who can access the server or your server gets hacked.


Should work like this:
Code: [Select]
// add group
addgroup  apacheyate

// add existing users for apache and yate to that group
useradd -G apacheyate apache
useradd -G apacheyate yate

// give group access to the file
chgrp apacheyate /usr/local/etc/yate where subscribers.conf

// give group permission on the file
chmod g+rw /usr/local/etc/yate where subscribers.conf

// remove write for all other users that are not owner of or in same group as file
chmod a-wx /usr/local/etc/yate where subscribers.conf


Pages: [1] 2 3 4