# TeamSpeak Usergroups Sync

**URL:** https://meta.discourse.org/t/teamspeak-usergroups-sync/119738
**Category:** Development
**Created:** [June 7, 2019, 12:38pm UTC](https://meta.discourse.org/t/teamspeak-usergroups-sync/119738 "2019-06-07T12:38:20Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![SvenC56](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/svenc56/32/132235_2.png) [@SvenC56](https://meta.discourse.org/u/SvenC56)
#### Post date: [June 7, 2019, 12:38pm UTC](https://meta.discourse.org/t/teamspeak-usergroups-sync/119738/1 "2019-06-07T12:38:20Z")

</div>

Hello together

I’m currently working on a synchronization service between Discourse and TeamSpeak to sync user groups from Discourse to TeamSpeak 3.

This service is already working and I’m tweaking it at the moment. First-time preparation takes about 20 minutes for you.

Technically seen this is a Node.Js server using a server query library.

[https://github.com/SvenC56/discourse-teamspeak-bridge](https://github.com/SvenC56/discourse-teamspeak-bridge)

I’m open to your feedback. 🙂

> **Readme.MD File**
>
> # Discourse - TeamSpeak 3 Server Bridge
> 
> It Ain’t Much But It’s Honest Work
> 
> [![Build Status](https://global.discourse-cdn.com/meta/original/3X/4/8/480508dbec2a8e6101154fbd55db52079c9e9757.svg)](https://travis-ci.com/SvenC56/discourse-teamspeak-bridge)
> 
> ## Getting started
> 
> This Bridge Server syncs specified user groups from the Discourse Board to the TeamSpeak 3 Server. The server runs a cronjob every 5 minutes to sync both servers. This server is in early dev stage but it is **fully working**.
> 
> On server start the server will create a database file which has to be filled by you. It is a pivot table which contains the Group\_ID of Discourse and TeamSpeak3.
> 
> ### Prerequisites
> 
> [better-sqlite3](https://github.com/JoshuaWise/better-sqlite3#installation) has some special installation requirements. I recommend to check out [this page](https://github.com/JoshuaWise/better-sqlite3#installation).
> 
> ### Installing
> 
> 1.) Install dependencies:
> 
> ```plaintext
> npm install
> 
> ```
> 
> 2.) Configure Environment Variables  
> Edit the `.env.example` file with your data.
> 
> 3.) Install the [Dataexplorer Plugin](https://meta.discourse.org/t/data-explorer-plugin/32566) in Discourse.
> 
> 4.) Add the following query.
> 
> ```sql
> -- [params] 
> -- string :custom_field_name 
> SELECT
> u.id AS user_id,
> u.username AS username,
> g.id AS group_id,
> ucf.value AS user_field_value 
> FROM
> users u 
> JOIN user_custom_fields ucf 
> ON ucf.user_id = u.id 
> join
> group_users gu 
> ON gu.user_id = u.id 
> join
> GROUPS g 
> ON g.id = gu.group_id 
> WHERE ucf.name = :custom_field_name 
> AND ucf.value <> ''
> ORDER BY g.id
> 
> ```
> 
> 5.) Create a custom Field in Discourse for the TeamSpeak UID.
> 
> 6.) Then you have to know which userfield name you are searching for.  
> This query will help you:
> 
> ```sql
> SELECT * FROM user_custom_fields
> 
> ```
> 
> ## Using the Webhook
> 
> This Server provides a Post-URL (`/webhook?secret=MYSECRET`) where you can trigger the synchronisation process. The Secret can be set in the Environment Variables.
> 
> ## Running the tests
> 
> At the moment no testing is done. This will be a part of future development.
> 
> ```plaintext
> npm run test
> 
> ```
> 
> ## Deployment
> 
> ```plaintext
> npm run build
> npm run serve
> 
> ```
> 
> **or**
> 
> ```plaintext
> npm run start
> 
> ```
> 
> ## API Documentation
> 
> **WIP:** In the development environment, you can access the `/explorer` route to debug and view all currently available routes.
> 
> ## Built With
> 
> - [Node.js](https://nodejs.org/en/)
> - [Express](https://expressjs.com/de/) - The Web-Framework
> 
> ## Authors
> 
> - **SvenC56** - _Initial work_ - [SvenC56](https://github.com/svenc56)
> 
> ## License
> 
> This project is licensed under the MIT License - see the LICENSE.md file for details
> 
> ## Acknowledgments
> 
> - [TS3-NodeJS-Library](https://github.com/Multivit4min/TS3-NodeJS-Library)

Thank you.

---

<div class="post-metadata">

### Author: ![SvenC56](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/svenc56/32/132235_2.png) [@SvenC56](https://meta.discourse.org/u/SvenC56)
#### Post date: [August 12, 2019, 5:56pm UTC](https://meta.discourse.org/t/teamspeak-usergroups-sync/119738/2 "2019-08-12T17:56:52Z")

</div>

Small Update:

- Dropped “better-sqlite” as dependency for “sqlite”.
- Added a Dockerfile and published the Image on Docker Hub: [https://cloud.docker.com/u/svenc56/r…amspeak-bridge](https://cloud.docker.com/u/svenc56/repository/docker/svenc56/discourse-teamspeak-bridge)
- Added a Webinterface to better manage the assignments.

 ![](https://global.discourse-cdn.com/meta/original/3X/e/f/ef7cc72f57cf4f2a7b34d295d5ffbf61f5991dda.png)

 ![image](https://global.discourse-cdn.com/meta/original/3X/c/7/c71b01cdb802e39e1a7ff613d10846131ba795e8.png)
