Complete newbie need help in understanding how this works

Hi all!
Im complete newbie when it comes to telephone systems, but i actually want to learn something new and hopefully play with it. I know that there are many cloud based services which would be cheaper for setup, but please not that i want to learn something. Money is not important as knowledge.

I will describe what im willing to build.
For start, i will have one analogue line. Next, i have enough knowledge to build web based applications and therefore i want to be able programmatically to make a call to another phone number outside my LAN network. For example i want login to my app where i have phone numbers of my friends, i will click to call button and call should be processed.
Also for example when somebody call back i want to detect that via web app and to be notified which friend calls me. If this is complicated i will be satisfied even with placing simple phone call…

After some researching i came up with some tutorials which are very confusing for me, so i just want to check if im on right track.

Is this what i need?

  1. Phone with lan interface connected to FXO gateway
  2. FXO gateway connected with IP box (Asterisk)
  3. FXO gateway connected with FXS (wall jack)

If yes, when i want to initiate a call, i have to send command to Asterisk. Then Asterisk will connect to FXO gateway and FXO gateway will do all the magic (if it is configured properly).

Now: is this how is it supposed to work or am i mistaken? Can it be simpler?

Thanks!

start by reading www.asteriskdocs.org. Then go deep with AMI, ami integration with DB, php call backs and possibly webrtc

There are may ways to do whatever you like. If you need to place or receive a call from the telephone company using an RJ-11 standard phone jack, you may want to look at purchasing an FXO card. Digium makes a 4 port card that you can add modules to. I have an analog card with 1 FXS (phone side) and 1 FXO (phone company side) port. You’ll need to configure dahdi to communicate with the Linux kernel, and chan_dahdi to communicate with Asterisk. On the inside, you could just as easily use a SIP-based phone connected to your network, or a soft(ware) phone installed on a computer or cell phone. If you go with either of those two, you won’t need an FXS module.

In /etc/dahdi/system.conf, you’ll need something like this…
loadzone = us
defaultzone=us
fxoks=1
fxsks=4

It defines the signalling for the card. FXS ports require FXO signalling and vice versa.

/etc/asterisk/chan_dahdi.conf will look something like this…
[channels]
usecallerid=yes
callwaiting=yes
usecallingpres=yes
callwaitingcallerid=yes
threewaycalling=yes
transfer=yes
canpark=yes
cancallforward=yes
callreturn=yes
echocancel=yes
echocancelwhenbridged=yes
callgroup=1
pickupgroup=1
callerid="Martin"
context=internal
signaling=fxo_ks
channel=>1

callerid=asreceived
context=inbound
signaling=fxs_ks
channel=>4

Your inbound context would just dial whatever internal extension you want, and you would dial out using something like this…
exten => _NXXZXXXXXX,1,Dial(DAHDI/4/${EXTEN})