Setup PostgreSQL for sending and receiving SMS

In this chapter you can learn about how to send and receive SMS messages using a PostgreSQL database server with your Ozeki Phone System. In this guide you can get information about the installation steps, the database connection string, the database connection type and the database table layout for PostgreSQL database server.

Figure 1 -

In order to send or receive SMS messages using a PostgreSQL database server, you need to following the instructions.

As the PostgreSQL database requires Open DataBase Connectivity (ODBC), select Odbc in the Connection string type dropdown menu. The Odbc driver for PostgreSQL can be available at the following webpage: http://pgfoundry.org/projects/psqlodbc/.

Odbc

Replace the default database connection string with the one for the PostgreSQL database in the Connection string template:

DRIVER={PostgreSQL};SERVER=YourServerIP;port=5432;DATABASE= YourDatabaseName;UID=YourUsername;PWD=YourPassword

Modify the variables in the connection string according to your needs.

The connection string and the connection type should be entered on the SQL SMS API configuration form.

specifying connection string for postgresql database
Figure 1 - Specifying the connection string for the PostgreSQL database

Figure 2 shows the SQL queries that will send the SMS messages from your database.

sql queries for receiving sms messages
Figure 2 - SQL queries for receiving SMS messages

Under the SQL for receiving tab, you need to provide an SQL query that will store the incoming SMS messages. Figure 3 shows the SQL query that you need to use.

sql query for sending sms messages
Figure 3 - SQL query for sending SMS messages

After the SQL SMS API has been configured in the Ozeki Phone System, you need to create the database tables for SQL SMS API. Use the following table layout:

-- -----------------------------------------------------
-- Table `OzekiPBX`.`ozpbxmessageout`
-- -----------------------------------------------------
CREATE TABLE ozpbxmessageout 
(
    id serial PRIMARY KEY, 
    sender varchar(30) NULL,
    receiver varchar(30) NULL,
    msg text NULL,
    senttime varchar(100) NULL,
    receivedtime varchar(100) NULL,
    reference varchar(100) NULL,
    status varchar(20) NULL,
    msgtype varchar(160) NULL,
    operator varchar(100) NULL,
    errormsg varchar(250) NULL
)

-- -----------------------------------------------------
-- Table `OzekiPBX`.`ozpbxmessagein`
-- -----------------------------------------------------
CREATE TABLE ozpbxmessagein
(
    id serial PRIMARY KEY, 
    sender varchar(30) NULL,
    receiver varchar(30) NULL,
    msg text NULL,
    senttime varchar(100) NULL,
    receivedtime varchar(100) NULL,
    extension varchar(100) NULL
)

It is strongly recommended to maintain an index in the database for the 'id' field of the outgoing SMS table to support faster SQL updates.

If you have any questions or need assistance, please contact us at info@ozekiphone.com.

Dig deeper!
People who read this also read...

More information