Infactum / tg2sip

Telegram <-> SIP voice gateway
GNU General Public License v2.0
273 stars 104 forks source link

How to connect the this to 3cx pbx #26

Closed vevees23 closed 4 years ago

vevees23 commented 4 years ago

can you provide tutorial on settings.ini

Infactum commented 4 years ago

Sorry but I don't have any 3CX PBX experience.

aizukanne commented 4 years ago

Here is a sample template for 3CX.

`<doc>
  <header>
    <name>Telegram Connect</name>
    <time>2020-05-09T11:29:58.6258523Z</time>
    <type>gateway-template</type>
  </header>
  <data>
    <device>
      <type>provider</type>
      <manufacturer></manufacturer>
      <model>provider</model>
      <field name="Name">Telegram Connect</field>
      <field name="RegistrarHost">127.0.0.1</field>
      <field name="RegistrarPort">0</field>
      <field name="ProxyHost"></field>
      <field name="ProxyPort">5060</field>
      <field name="SecondaryRegistrar"></field>
      <field name="IPRestriction">ANY</field>
      <field name="TransportRestriction">UDP</field>
      <field name="RequireAuthFor">1</field>
      <field name="IpInContactReg">2</field>
      <field name="IpInContactRegValue"></field>
      <field name="TimeBetweenRegistration">600</field>
      <field name="RegistrarInvite">0</field>
      <field name="IsSupportReinvite">1</field>
      <field name="IsSupportReplaces">0</field>
      <field name="DisableVideo">0</field>
      <field name="SecureRTP">0</field>
      <field name="IsBindToMS">1</field>
      <codecs>
        <codec rfcname="opus" />
        <codec rfcname="pcmu" />
        <codec rfcname="pcma" />
        <codec rfcname="g729" />
      </codecs>
      <field name="ParameterIn" custom="" parameter="ToUserPart">$CalledNum</field>
      <field name="ParameterIn" custom="" parameter="FromDisplayName">$CallerName</field>
      <field name="ParameterIn" custom="" parameter="FromUserPart">$CallerNum</field>
      <field name="ParameterOut" custom="" parameter="RequestLineURIUser">$CalledNum</field>
      <field name="ParameterOut" custom="" parameter="RequestLineURIHost">$GWHostPort</field>
      <field name="ParameterOut" custom="" parameter="ContactUser">$AuthID</field>
      <field name="ParameterOut" custom="" parameter="ContactHost">$ContactUri</field>
      <field name="ParameterOut" custom="" parameter="ToDisplayName">$CalledName</field>
      <field name="ParameterOut" custom="" parameter="ToUserPart">$CalledNum</field>
      <field name="ParameterOut" custom="" parameter="ToHostPart">$GWHostPort</field>
      <field name="ParameterOut" custom="" parameter="FromDisplayName">$OutboundCallerId</field>
      <field name="ParameterOut" custom="" parameter="FromUserPart">$AuthID</field>
      <field name="ParameterOut" custom="" parameter="FromHostPart">$GWHostPort</field>
      <field name="ParameterOut" custom="" parameter="RemotePartyIDCallingPartyDisplayName">$OutboundCallerId</field>
      <field name="ParameterOut" custom="" parameter="RemotePartyIDCallingPartyUserPart">$OutboundCallerId</field>
      <field name="ParameterOut" custom="" parameter="RemotePartyIDCallingPartyHostPart">$GWHostPort</field>
      <field name="ParameterOut" custom="" parameter="P-AssertedIdentityDisplayName">$OutboundCallerId</field>
      <field name="ParameterOut" custom="" parameter="P-AssertedIdentityUserPart">$OutboundCallerId</field>
      <field name="ParameterOut" custom="" parameter="P-AssertedIdentityHostPart">$GWHostPort</field>
    </device>
  </data>
</doc>`

Save as XML and import the template then make any changes you require.

For tg2sip set the following in addition to API ID and API hash. id_uri= callback_uri= raw_pcm=false udp_p2p=true

I hope that helps.

fergalom commented 4 years ago

@aizukanne I have tg2sip setup and configured correctly I believe

Loading config Env.TG2SIP_STANDARD_FOLDER exist Using standard folder [19:28:52.006][t:1][p:1][pjsip][info] pjsua version 2.9 for Linux-3.10.4.38/x86_64/glibc-2.28 initialized [19:28:52.044][t:14][p:1][core][info] TG client authorization ready [19:28:52.044][t:1][p:1][core][info] Loading contacts cache [19:28:52.121][t:14][p:1][core][info] TG client connected [19:28:52.152][t:1][p:1][core][info] Loaded 6 usernames and 13 phones into contacts cache [02:53:47.894][t:14][p:1][core][info] TG client connected

settings.ini [logging] core=1 [sip] public_address=domain.3cx.com port=5060 id_uri=sip:201@domain.3cx.com callback_uri=sip:201@domain.3cx.com:5060 raw_pcm=false [telegram] api_id=1234567 api_hash=xyzxyzxyz123 udp_p2p=true

Is the import of the XML template above a requirement to get 3CX working?

Also, I'm missing a step here but how for example can I make / receive sip calls to / from 201@domain.3cx.com in telegram?

aizukanne commented 4 years ago

The configuration is in two parts.

  1. Configure tg2sip (which you have one)
  2. Configure a trunk/SIP endpoint in 3CX.

The template is required to create a SIP Trunk (peer) in 3CX. However, it looks like you are configuring a connection as a SIP client (friend). I have not tried that. I connected ts2sip as a SIP Trunk. To configure a trunk, 3CX will require a 4 digit number for the trunk so "201" will not work.

Once you have both ends configured, try to make a call from telegram. Remember to uncomment the lines with specific configurations you want to apply in settings.ini.

Good luck

fergalom commented 4 years ago

@aizukanne Ah, ok, will go with the trunk. Can you share your settings.ini?

vevees23 commented 4 years ago

thank you @aizukanne

synetalsolutions commented 3 years ago

How can I make calls from telegram?