Server Side Microsoft SQL Server, MySQL, PostgreSQL Database Integration (2024)

  • Introduction
  • Step 1: Configure 3CX
  • Step 3: Configure Contact Creation
  • See Also

Introduction

3CX provides integration with SQL databases via the 3CX API for CRM with the following features:

  • Caller ID to Contact Name– inbound calls trigger an SQL database contact lookup.
  • Contact Lookup in SQL database based on Name, Number or Email if you search for a name in the 3CX Webclient
  • Call & Chat Journalling– calls and chats are logged in the SQL database.
  • Create a new SQL database contactfrom the 3CX client for calls from new numbers.
  • Click to Call– Providing that your system is a web application, launch calls straight from your system via 3CX, using the 3CX Click2Call Browser extensions for Google Chromeand Microsoft Edge.

Step 1: Configure 3CX

Server Side Microsoft SQL Server, MySQL, PostgreSQL Database Integration (1)

  1. In the 3CX Admin Console go to “Integrations” > “CRM”. Select your SQL database type from the dropdown list. In order to integrate with MariaDB, please select the MySQL Database option and proceed as usual.
  2. Enter the connection information:
  • Server: the server name or IP address. For MS SQL Server can include the instance name or port number when needed, e.g.:
  1. myServerName

  2. myServerName\myInstanceName

  3. myServerAddress,Port

  • Port: the port number on which the connection must be established. Not applicable to MS SQL Server.
  • Database: the name of the database to use.
  • Username: the username to use to connect to the database.
  • Password: the password to use to connect to the database.
  1. Enter the Lookup By Number SQL Statement. This will be used when doing the lookup for calls or chat interactions through SMS. This must be a SELECT statement returning the following case-sensitive columns:

    contactid

    ,

    firstname

    ,

    lastname

    ,

    companyname

    ,

    email

    ,

    phonemobile

    ,

    phonemobile2

    ,

    phonehome

    ,

    phonehome2

    ,

    phonebusiness

    ,

    phonebusiness2

    ,

    phoneother

    ,

    faxbusiness

    ,

    faxhome

    ,

    pager

    ,

    photourl

    . If your database table has different column names, you can change the name returned as follows:

SELECT id as contactid, first_name as firstname, last_name as lastname, email as email, phone as phonebusiness, mobile as phonemobile, fax as faxbusiness FROM contacts WHERE phone LIKE CONCAT('%',@Number,'%') or mobile like CONCAT('%',@Number,'%')or fax LIKE CONCAT('%',@Number,'%')

. If your numbers contain characters or spaces except digits and +, you must write a SQL function to return normalized numbers before returning them to 3CX.

  1. Enter the Lookup By Email SQL Statement. This will be used when doing the lookup for Live Chat interactions. This must be a SELECT statement returning the following case-sensitive columns:

    contactid

    ,

    firstname

    ,

    lastname

    ,

    companyname

    ,

    email

    ,

    phonemobile

    ,

    phonemobile2

    ,

    phonehome

    ,

    phonehome2

    ,

    phonebusiness

    ,

    phonebusiness2

    ,

    phoneother

    ,

    faxbusiness

    ,

    faxhome

    ,

    pager

    ,

    photourl

    . If your database table has different column names, you can change the name returned as follows:

SELECT id as contactid, first_name as firstname, last_name as lastname, email as email, phone as phonebusiness, mobile as phonemobile, fax as faxbusiness FROM contacts WHERE email = @Email

. If your numbers contain characters or spaces except digits and +, you must write a SQL function to return normalized numbers before returning them to 3CX.

  1. Enter the Search Contacts SQL Statement. This will be used when searching contacts from the Web Client. You should search for the text in any field in your database. This must be a SELECT statement returning the following case-sensitive columns:

    contactid

    ,

    firstname

    ,

    lastname

    ,

    companyname

    ,

    email

    ,

    phonemobile

    ,

    phonemobile2

    ,

    phonehome

    ,

    phonehome2

    ,

    phonebusiness

    ,

    phonebusiness2

    ,

    phoneother

    ,

    faxbusiness

    ,

    faxhome

    ,

    pager

    ,

    photourl

    . If your database table has different column names, you can change the name returned as follows:

SELECT id as contactid, first_name as firstname, last_name as lastname, email as email, phone as phonebusiness, mobile as phonemobile, fax as faxbusiness FROM contacts WHERE first_name LIKE CONCAT('%',@SearchText,'%')or last_name LIKE CONCAT('%',@SearchText,'%')or phone LIKE CONCAT('%',@SearchText,'%')or mobile like CONCAT('%',@SearchText,'%')or fax LIKE CONCAT('%',@SearchText,'%')

. If your numbers contain characters or spaces except digits and +, you must write a SQL function to return normalized numbers before returning them to 3CX.

  1. Enter the Contact URL prefix and suffix. These are required to create the Contact URL, which is the concatenation of the Contact URL Prefix, the ContactID returned by the database, and the Contact URL Suffix. This Contact URL is considered the key for the contact in 3CX Contacts, and is used to update the contact if any change is detected in the database. Also, this Contact URL is shown in the 3CX Web Client, so if you have a web page to show the contact record, use these settings to create the URL to point to that page.

Step 2: Configure Call & Chat Journaling

Server Side Microsoft SQL Server, MySQL, PostgreSQL Database Integration (2)

  1. If you want to report external calls to the database, check the Enable Call Journaling checkbox and configure the Call Journaling SQL Statement.
  2. Please note that you can use variables in the Call Journaling SQL Statement. Variables are specified with the @ prefix, for example the external number is specified as @Number. The available variables to use are listed here.
  3. Your Call Journaling SQL Statement should be an INSERT statement, for example:

For MS SQL:

INSERT INTO calls (contactnumber, agentextension, description, calldatetime, callduration) VALUES (@Number, @Agent, '3CX PhoneSystem Call', CONVERT(VARCHAR, @CallStartTimeUTC,127), @Duration)

For MySQL:

INSERT INTO calls (contactnumber, agentextension, description, calldatetime, callduration) VALUES (@Number, @Agent, '3CX PhoneSystem Call', DATE_FORMAT(@CallStartTimeUTC, '%Y-%m-%dT%H:%i:%s%Z'), @Duration)

For PostgreSQL:

INSERT INTO calls (contactnumber, agentextension, description, calldatetime, callduration) VALUES (@Number, @Agent, '3CX PhoneSystem Call', TO_CHAR(@CallStartTimeUTC, 'YYYY-MM-DD"T"HH24:MI:SS"Z"'), @Duration)

Server Side Microsoft SQL Server, MySQL, PostgreSQL Database Integration (3)

  1. If you want to report chats to the database, check the Enable Chat Journaling checkbox and configure the Chat Journaling SQL Statement.
  2. Please note that you can use variables in the Chat Journaling SQL Statement. Variables are specified with the @ prefix, for example the external number is specified as @Number. The available variables to use are listed here.
  3. Your Chat Journaling SQL Statement should be an INSERT statement, for example:

For MS SQL:

INSERT INTO chats (email, agentextension, subject, description, calldatetime, callduration) VALUES (@Email, @Agent, '3CX PhoneSystem Chat Session', @ChatMessages, CONVERT(VARCHAR, @ChatStartTimeUTC,127), @Duration)

For MySQL:

INSERT INTO chats (email, agentextension, subject, description, calldatetime, callduration) VALUES (@Email, @Agent, '3CX PhoneSystem Chat Session', @ChatMessages, DATE_FORMAT(@ChatStartTimeUTC, '%Y-%m-%dT%H:%i:%s%Z'), @Duration)

For PostgreSQL:

INSERT INTO chats (email, agentextension, subject, description, calldatetime, callduration) VALUES (@Email, @Agent, '3CX PhoneSystem Chat Session', @ChatMessages, DATE_FORMAT(@ChatStartTimeUTC, '%Y-%m-%dT%H:%i:%s%Z'), @Duration)

Step 3: Configure Contact Creation

Server Side Microsoft SQL Server, MySQL, PostgreSQL Database Integration (4)

  1. To create new contacts in the database when the caller number can’t be found, check the “Allow contact creation directly to your CRM using 3CX Web Client” checkbox and configure the “Contact Creation from Client SQL Statement”.
  2. Please note that you can use variables in the SQL Statement. Variables are specified with the @ prefix, for example the external number is specified as @Number. The available variables to use are listed here.
  3. The Contact Creation SQL Statement must return the following case-sensitive columnsfor the contact created:

    contactid

    ,

    firstname

    ,

    lastname

    ,

    companyname

    ,

    email

    ,

    phonemobile

    ,

    phonemobile2

    ,

    phonehome

    ,

    phonehome2

    ,

    phonebusiness

    ,

    phonebusiness2

    ,

    phoneother

    ,

    faxbusiness

    ,

    faxhome

    ,

    pager

    ,

    photourl

    . You can change the name of the columns returned using the same technique explained above for the Lookup SQL Statement.
  4. For the Contact Creation SQL Statement, you can use a combined statement, inserting the record first, and querying it later. For example:

INSERT INTO contacts (first_name, last_name, phone) VALUES (@FirstName, @LastName, @Number);SELECT id as contactid, first_name as firstname, last_name as lastname, phone as phonebusiness FROM contacts WHERE phone = @Number

  1. When the caller’s number can’t be matched to a contact, the 3CX client will let the user create the contact by filling the details in a dialog.

See Also

  • See how to integrate your CRM with the 3CX API.
  • Learn how to set up Bitrix24 integration.
  • Learn how to set up Freshdeskintegration.
  • Learn how to set up HubSpotintegration.
  • Learn how to set up Jetpack CRMintegration.
  • Learn how to set up Zendeskintegration.
  • Learn how to set up MongoDBintegration.

Last Updated

This document was last updated on 18 December 2023

https://www.3cx.com/docs/sql-database-pbx-integration/

Discuss this article

Server Side Microsoft SQL Server, MySQL, PostgreSQL Database Integration (2024)

FAQs

How to connect PostgreSQL database to Microsoft SQL Server? ›

Configure the DataDirect ODBC PostgreSQL Driver with Microsoft SQL Server Management Studio.
  1. Launch SQL Server Management Studio.
  2. Navigate to Server Objects > Linked Servers > Providers > MSDASQL > and confirm that the Allow inprocess and non-transacted updates options are Enabled.
Jan 4, 2023

Is PostgreSQL same as Microsoft SQL Server? ›

While both systems share many core features, there are some key differences—the major one being that PostgreSQL is open source and SQL Server is owned by Microsoft. Today, it is more vital than ever for companies to be able to manage, store, and activate data for modern business operations.

Can I run MySQL and PostgreSQL on the same server? ›

MySQL and PostgreSQL can run just fine on the same server together. It sounds like you've already got one instance of Postgres running. Try a ps ax | grep postmaster or similar to determine if the server daemon process is already running.

What is the difference between MySQL and Microsoft SQL Server? ›

MySQL is open source. SQL Server is proprietary software and has a cost. With MySQL, you can edit databases at run time. With SQL Server, you can't edit or access files at run time.

How to connect to MySQL database using PostgreSQL? ›

Connect to PostgreSQL through the SQL Gateway
  1. In MySQL Workbench, click to add a new MySQL connection.
  2. Name the connection (CData SQL Gateway for PostgreSQL).
  3. Set the Hostname, Port, and Username parameters to connect to the SQL Gateway.
  4. Click Store in Vault to set and store the password.

How do I connect to a Microsoft SQL Server database? ›

Start SQL Server Management Studio. The first time you run SSMS, the Connect to Server window opens. If it doesn't open, you can open it manually by selecting Object Explorer > Connect > Database Engine. For Server type, select Database Engine (usually the default option).

What is the difference between MySQL and PostgreSQL? ›

Indexes: Both PostgreSQL and MySQL include support for different indexing techniques. However, PostgreSQL offers some advanced indexing types (like GIN and GiST), which are not available in MySQL. Standard SQL Data Types: The standard SQL data types (like INTEGER and VARCHAR) are available in both MySQL and PostgreSQL.

Should I use PostgreSQL or SQL Server? ›

While PostgreSQL can be used for almost any operating system and is suitable for small businesses that require maximum functionality, SQL Server is the best for huge businesses, especially those that require the use of Microsoft products.

Should I learn SQL or PostgreSQL first? ›

For students who have little to no experience with SQL and are looking to gain the most broadly applicable skills, I recommend starting with PostgreSQL. Despite the overwhelming popularity of MySQL, PostgreSQL may be a better choice because its syntax most closely conforms to Standard SQL.

What is the difference between SQL and PostgreSQL? ›

Operating Systems: PostgreSQL is designed to run on multiple operating systems, including Linux, macOS, and Windows, while SQL Server is primarily designed to run on Windows, but can also be run on Linux.

How to transfer data from MySQL server to PostgreSQL? ›

Follow the following steps to migrate data from MySQL to PostgreSQL successfully.
  1. Step 1: Install the Py-mysql2pgsql Tool On Your System.
  2. Step 2: Once Done, Verify Your Installation.
  3. Step 3: Edit the mysql2pgsql. yml Migration Configuration File.
  4. Step 4: Start Migrating Data from MySQL to PostgreSQL.
May 3, 2023

How do I connect to a MySQL database from another server? ›

Grant access
  1. Log in to your MySQL server locally as the root user by using the. following command: # mysql -u root -p. You are prompted for your MySQL root password. ...
  2. Use a GRANT command in the following format to enable access for the. remote user. Ensure that you change 1.2.3.4 to the IP address that you.

Why PostgreSQL is better than MySQL? ›

MySQL has limited support of database features like views, triggers, and procedures. PostgreSQL supports most advanced database features like materialized views, INSTEAD OF triggers, and stored procedures in multiple languages. MySQL supports numeric, character, date and time, spatial, and JSON data types.

Should I use MySQL or MS SQL? ›

MySQL is known for being easy to use, reliable, and scalable, making it a great choice for businesses looking to save costs and work with different operating systems and programming languages. On the other hand, MSSQL, developed by Microsoft, offers strong security features and works seamlessly with Windows.

Which is faster SQL Server or MySQL? ›

Performance: MySQL is designed for high-performance data processing and can handle high traffic websites and applications with ease. SQL Server offers good performance but requires more system resources and hardware to achieve the same level of performance as MySQL.

How do I connect to SQL Server from pgAdmin? ›

Connect to Server¶

To access the dialog, right click on the server name in the pgAdmin tree control, and select Connect Server… from the context menu. Provide authentication information for the selected server: Use the Password field to provide the password of the user that is associated with the defined server.

How to connect PostgreSQL database to Access database? ›

Importing PostgreSQL Data Into Microsoft Access Through an ODBC Connection
  1. Open your Microsoft Access database.
  2. Select the External Data tab in the ribbon.
  3. Expand the New Data Source drop-down and select From Other Sources, then select ODBC Dababase.

How to connect to Postgres database using SQL shell? ›

Launch the “SQL Shell” and specify the login details to connect to the Postgres database server via the “psql”. Open the “pgAdmin”, provide the superuser password, and hit the “o*k” button to connect to the Postgres Database Server via pgAdmin.

How to connect to Postgres database from SSIS? ›

To connect to PostgreSQL, set the Server, Port (the default port is 5432), and Database connection properties and set the User and Password you wish to use to authenticate to the server. If the Database property is not specified, the data provider connects to the user's default database.

Top Articles
Latest Posts
Article information

Author: Roderick King

Last Updated:

Views: 5462

Rating: 4 / 5 (51 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Roderick King

Birthday: 1997-10-09

Address: 3782 Madge Knoll, East Dudley, MA 63913

Phone: +2521695290067

Job: Customer Sales Coordinator

Hobby: Gunsmithing, Embroidery, Parkour, Kitesurfing, Rock climbing, Sand art, Beekeeping

Introduction: My name is Roderick King, I am a cute, splendid, excited, perfect, gentle, funny, vivacious person who loves writing and wants to share my knowledge and understanding with you.