The recent posts about setting Teams presence and being notified about Teams presence changes are the building blocks to synchronize the presence state between MS Teams and our 3CX PBX both ways.
- a call on Teams sets the 3CX presence state to "Away" if it was "Available" before
- if Teams becomes "Available" and 3CX state is "Away" => set 3CX to "Available"
- a call on 3CX tries to set the Teams presence "Busy" - there is some logic behind the scenes, we can't control about overriding "Offline" and "Away" in Teams which comes in handy in this case
In order to interact with the 3CX PBX there is an inoffical call flow API for v16 which has been adopted by the 3cx-web-api project. Apart from TAPI and CRM integrations this seems to be the only way to react to call states as well as set the presence state.
The API is written in C# using the .Net 5.0 framework since 3CX is a .Net application. It would have been nice to incorporate the presence functionality I coded in Bash into the 3cx-web-api. Unfortunately my coding skills are somewhat basic, especially when it comes to MVC design patterns which are used throughout all Microsoft identity sample projects.
I did manage to extend the 3cx-web-api to handle the notification webhook. That spares the use of the rudimentary webserver+socat of the previous post.
In order to direct traffic to the API I modified the /etc/nginx/sites-enabled/3cxpbx (normally a sym-link) and added an upstream and location setting:
... upstream webapi { server 127.0.0.1:1234; } ... server { ... location ~ ^/secret-url-teams-presence-notification { proxy_pass http://webapi; } ...
Note: in this setup the path-name is the only "secret", preventing anybody to tamper with your PBX!!!
After building the 3cx-web-api according to the README.md, the StdOut of the program can be used to handle presence changes in a Bash script.
The files from the previous two posts handle the Microsoft communication.
I have attempted to replicate your scripts and i think i have it setup correctly with the MS Teams auth files. When i run the script above it just immediately ends and no looping of the StdOutput takes place. I am running this on the 3cx machine itself on Debian. If you can give me some advice i would appreciate it. I want to do exactly what you describe for my users and i would love to get this working on my 3cx.
AntwortenLöschenHi HP, could we possibly take this to Github: https://github.com/adn77/3cx-web-API/issues
LöschenComments here tend to get messy ;)
Thank you for replying Alexander. I can do that but the issues I seem to be having aren't specifically related to the API, which works well and is able to run properly. I need help to figure out why StdOutput doesn't run when the script above is launched and likely with the MS Teams authentication part too. Okay for me to open an issue at Github on that basis?
AntwortenLöschenHello. I need this setup for a customer urgently and i am willing to pay for your time to help me get it working. I have spent may hours trying everything using your files but i need help from someone that knows how to get it working. Please consider my request, i am happy to pay for this as the client is important to me.
AntwortenLöschenI will be back home in two days, how would you like me to contact you?
LöschenThanks for responding. Please email me sohost at gmail dot com
LöschenI am still interested to get your paid help if you are available. I just need a solution for this client and your scripts will solve their issues, but I'm unable to get it to work. Email me if you are interested - sohost at gmail and we can discuss further. Thank you.
AntwortenLöschen