Any example LUA scripts

Good morning everybody. Has somebody any example of lua script? How to start with it?

@dmitry.s, maybe you have idea how to use LUA here ?

lua scripting still not working - under development. We will mention it in release notes when it will be ready.

@dmitry.s, is there anything new about using the lua script? I would like to use it to manipulate the src callerid based on the dst callerid variable.

Thakns!

could you add details what you want implement?

yes of course!

Imagine that my user sip has the src number 554132321010 (fixed number BR) and send invite to dst number 5531991101010 (mobile number BR).

I would like transform the src number (554132321010) to (553132321010) and If the same user sip send invite to dst number 5521988811010 i would like transform the src number (554132321010) to (552132321010).

I belive that lua script is a better solution.

But if there some way using Src rewrite rule and regex with some variable about dst number is valid too.

you can achieve it using destination numberlist where keys will be destination numbers and src_rewrite_rule/result will apply rewrite depends on matched key.

I understood your suggestion. Thanks. However maybe I failed to explain it properly to you.

The destination number is random and I need to change the source number based on the third and fourth digit of the destination number.

Using AGI in Asterisk (Perl/python/node/java/php) and regex currently I do the following action:

SRC = 5521987654321
DST = 5511912345678
$VarTemp1 = substr( SRC, 4, 9 );
$VarTemp2 = substr( DST, 2, 2 );
SRC = “55” + $VarTemp2 + $VarTemp1;

The result would be:
SRC = 5511987654321
DST = 5511912345678

DST is dynamic, so I think it’s better to use LUA script.

It would also be nice to use the LUA scripts to take say destination rates in one format, and using the script, it converted to the format understood by Yeti switch. Hence, rates from other vendors are simply uploaded with the applicable scripts specified. (with API support also)

In my case I think lua has fix to insert params into URI

I need supply to upstream
tgrp param

;tgrp=tg55;trunk-context=telco.example.com

or

DTG

;dtg=CONTEXT@172.29.199.176:5060;


Will be really helpful