Tg2SIP is a Telegram <-> SIP voice gateway. It can be used to forward incoming telegram calls to your SIP PBX or vice versa.
Your SIP PBX should be comaptible with L16@48000 or OPUS@48000 voice codec.
- Obtain binaries in one of convenient ways for you.
- Obtain
api_idandapi_hashtokens from this page and put them insettings.inifile. - Login into telegram with
gen_dbapp - Set SIP server settings in
settings.ini - Run
tg2sip
SIP -> Telegram calls can be done using 3 extension types:
tg#[\s\d]+for calls by username\+[\d]+for calls by phone number[\d]+for calls by telegram ID. Only known IDs allowed by telegram API.
All Telegram -> SIP calls will be redirected to callback_uri SIP-URI that can be set in from settings.ini file.
Extra information about Telegram account caller will be added into SIP headers:
X-TG-Context: Special header for debug purposeX-TG-ID: Telegram User IdX-TG-FistName: Optional, User first nameX-TG-LastName: Optional, User last nameX-TG-Username: Optional, User usernameX-TG-Phone: Optional, User phone number
git clone https://github.com/hectorvent/tg2sip
cd tg2sip
./build.sh
# build directory will be create and gen_db, tg2sip and settings.ini will exist# Install dependencies.
apt install libopus0 libssl1.1 -y
# Create directory structure
mkdir /etc/tg2sip
mkdir /var/tg2sip
cp build/{tg2sip,gen_db} /usr/local/bin
# nano/vi /etc/tg2sip/settings.ini and change necessary values.
cp settings.ini /etc/tg2sip/
# Copy systemd service
cp tg2sip.service /etc/systemd/system
systemctl daemon-reload
# create Telegram Tdlib db and fill the requested information
sudo TG2SIP_STANDARD_FOLDER=YES gen_db
# start the tg2sip gateway and enjoy it.
systemctl start tg2sip.serviceDocker Tg2SIP image is based on Debian 10
cd docker
cp ../settings.ini etc
# Edit settings file
nano etc/settings.ini
# Generate Telegram db
docker run --rm -it -v `pwd`/etc:/etc/tg2sip/ -v `pwd`/data:/var/tg2sip/ hectorvent/tg2sip-gateway gen_db
# start docker services
docker-compose up -d- Upgrade
Tdlibto new version. - Integration examples with
Asterisk,FreeSwitchandKamailio. - A better Tdlib db initialization process. It is possible to create an API.
As this repo is based on Infactum/tg2sip make donation to Infactum.