Dial-out retrive information

Goodmorning
i try to create an auto-dialer on asterisk.

i need to call some number and retrive what the client digit on the phone it could be the flow chart:

call->playmessage->trap phone typing

if 1 agree–>say goodbye>save number on db
if 2 decline–>say goodbye–>close comunication
if 3 repeat message

there are some example code i could follow ?

thanks

Marco

Google: Autodialer asterisk & AGI Get_data.

hundreds of examples available on the net.

There’s like a million different ways to complete this task.

This is one of them : Use php fsockopen function to connect to the Asterisk AMI, then use the AMI Originate Action to initiate the call, On the Asterisk dial plan side use the Read() app (It Read a variable in the form for DTMF tones as pressed by the caller).

On the DB part you , Use MYSQL and the Asterisk System() command to save the data on the DB.

Related to share some sample code , this is a support community where members exchange thoughts and provide general support, The request of custom codes or samples code. Must be addrssed on the job section.

In case some member is willing to share some sample code, it is an extra mile.

Thanks in advice i’m working on it.

for know i create this i preferrred make it with .call file for create a base this my code:

a-out.call
Channel: SIP/282
MaxRetries: 5
RetryTime: 300
WaitTime: 45
Context: from-pstn
Extension: 1234
Priority: 1

Extension.conf

[from-pstn]
exten => 1234,1,Answer();
exten => 1234,n,Set(TIMEOUT(digit)=1);
exten => 1234,n,Set(TIMEOUT(response)=10);
exten => 1234,n,Background(welcome);
exten => 1234,n,Background(call-forwarding);
exten => 1234,n,SayDigits(12)
exten => 1234,n,WaitExten();

exten => 1,1,Playback(hello-world);

//
exten => 1,n,MYSQL(Connect tocrm localhost autodialer autodialer finaziamenti);
exten => 1,n,MYSQL(Query resultid ${tocrm} INSERT INTO autodialer(phone_number) VALUES (‘282’);
exten => 1,n,MYSQL(Disconnect ${tocrm})
//Not working

exten => 1,n,Playback(hello-world);

I’d recommend using func_odbc over the MySQL command personally but it looks like you have a good idea of what to do.

You may want to add a variable in your call file that contains what number you called, then you can use it in your ‘1’ extension.

thanks i working two days on it
i’m a noob on asterisk but i can do what i need to do :slight_smile:

soo hard for me :slight_smile: :slight_smile: :slight_smile:

With func_odbc it’d look something like this:

You would need to make an entry in /etc/odbc.ini

[mysql_autodialer]
Description     = MySql connection for autodialer database
Driver          = MySql
Trace           = No
Server          = localhost
port            = 3306
database        = MyDatabase
user            = MyUser
password        = MyPassword

You would have to modify res_odbc.conf to create an entry for your ODBC connection.

[odbc_autodialer]
enabled => yes
dsn => mysql_autodialer
username => MyUserName
password => MyPassword
pre-connect => yes

define your function in func_odbc.conf

[ACCEPTED]
dsn=odbc_autodialer
writesql=INSERT INTO autodialer (phone_number) VALUES('${VAL1}');

in your extensions.conf

exten => 1,1,Set(ODBC_ACCEPTED()=${DialedNumber}) 
 same =>   n,ExecIf($[${ODBCROWS} < 1]?Playback(an-error-has-occured):Playback(auth-thankyou))
 same =>   n,Hangup()

Thanks a lot, when i finish i post my code for sharing into the community :slight_smile:

best regards
Marco

1 Like