A custom "variable" with cel

With CDR I want a custom field

So I set a var

[global]
PHONEEXTNUMBER=0.....67

On contest I put the custom cdr field called original_dst which read
PHONEEXTNUMBER

[uscita]
exten = s,1,NoOp()
same => n,Set(CDR(original_dst)=${PHONEEXTNUMBER})
same => n,Dial(PJSIP/telefono1&DAHDI/17,30,tTkK)
same => n,Hangup()

I use mysql backend so I add the custom field (original_dst)

alter table cdr add COLUMN original_dst varchar (80) AFTER dst;

The field is recorded! (0…67)

| 2023-02-12 12:54:10 | "CALLER" <******> | ***** | s | 0.....67 | uscita | PJSIP/asterisk01-00000000 | DAHDI/17-1 | Dial | PJSIP/telefono1&DAHDI/17,30,tTkK | 2 | 0 | NO ANSWER | 3 | | asterisk1-****** |

My question is…is possible this using CEL?
Thanks

I don’t think you can add custom fields to CEL, but there is already a
“userfield” which you can put whatever data you like into:

same => n,Set(CHANNEL(userfield)=${ConvID})

See also CEL Custom Event Field
CEL custom field

Antony.

You can create a custom event, to associate the variable with the channel, although, in this case, I think you can reconstruct the information you want from the standard events, as CEL will log events before the GoTo that changes the destination number, as well as after it.

1 Like

Thanks
I have proceed like this

vim cel.conf

events=APP_START,CHAN_START,CHAN_END,ANSWER,HANGUP,BRIDGE_ENTER,BRIDGE_EXIT,USER_DEFINED

vim extensions.conf

same => n,CELGenUserEvent(exitnumber,[,${PHONEEXTNUMBER}])

After made a call…

select userdeftype from cel order by userdeftype limit 2 offset 30;
+-------------+
| userdeftype |
+-------------+
|             |
|             |
+-------------+

I try also this query

 select userdeftype,userfield from cel order by userdeftype limit 11 offset 30;
+-------------+-----------+
| userdeftype | userfield |
+-------------+-----------+
|             |           |
|             |           |
|             |           |
|             |           |
|             |           |
|             |           |
|             |           |
|             |           |
|             |           |
+-------------+-----------+
9 rows in set (0,035 sec)

Of course cel and cel_odbc are realoaded and on cel_odbc I have enabled
show_user_defined=yes

A little progress…

same => n,Set(CHANNEL(userfield)=${PHONEEXTNUMBER})

write the var in userfield sql column.

Now the question is…is possible to add a custom colum called for example “extnum” and then write to it using

same => n,Set(CHANNEL(extnum)=${PHONEEXTNUMBER})

?

No.

The only way I can think of getting close to what you’re looking for is to
select a delimiter which will never appear in any of your data fields, and
concatentate them together using this delimiter into a single value which you
put into the userfield.

By default the userfield is defined as a varchar(255) - if this is insufficient it
may be possible simply to alter the table schema so you can fit more data into
it. I’m definitely not certain about that, though.

Antony.

1 Like

I think you are trying to use CEL as though it was producing CDRs. You should be thinking in terms of integrating several events to collect the information you want.

The way of adding general user information to a channel is called setting a channel variable!

It looks to me as though the sqlite3 backend would allow you to include an extra field, and probably take it from a channel variable, but none of the other database backends do.

The CSV file also allows such customisation.

1 Like

“You were rather late in telling us you were using a database.”

To be fair to the OP, the original question did include “I use mysql backend
so I add the custom field (original_dst)”…

I think most people using a DB for CDR would also be using it for CEL.

Antony.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.