Sync Client V2

The Sync Client can be used to transfer all updates on contacts to an SQL database or a web service.

Activation

To be able to use the Sync Client, activate the corresponding connector in the campaign settings. After successful activation, a token is displayed below the connectors. It is required to use the client. The token is only visible to the user who activated the connector.

Alternativtext wenn Bild nicht gefunden

Installation

Download of the binary from bitbucket

Download and compile source code

Install Git

sudo apt-get install git

Install Google Go

sudo apt-get install golang-go

For the further steps it is necessary that the environment variable GOPATH is set. A description of how to set the GOPATH environment variable correctly can be found here.

Clone the repository

go get bitbucket.org/modima/dbsync2

Install all dependencies

cd $GOPATH/src/bitbucket.org/modima/dbsync && godep restore

Compile the source code

  • Target platform Linux

    cd $GOPATH/src/bitbucket.org/modima/dbsync2/ && go build
    
  • Target platform Windows

    cd $GOPATH/src/bitbucket.org/modima/dbsync2/ && GOOS=windows GOARCH=amd64 go build -o dbsync2.exe
    
  • Target platform Mac

    cd $GOPATH/src/bitbucket.org/modima/dbsync2/ && GOOS=darwin GOARCH=amd64 go build -o dbsync2_mac
    

How it works

All updates on contacts are loaded every minute from Dialfire and then transferred directly to the web service or database (see Usage).

Usage

SQL database

The client currently supports the following database systems:

  • MySQL / MariaDB
  • PostgreSQL
  • Microsoft SQL Server

Before you can use the client with a database, the corresponding database must be created.

The client creates the following 4 tables within that database:

  • dfire_contacts
    • Contains all $ fields, as well as the first 100 custom fields of the campaign.
  • dfire_transactions
    • Contains all transactions and the foreign key contact_id on the corresponding contact.
  • dfire_connections
    • Contains all connections of the transaction and the foreign key transaction_id to the corresponding transaction.
  • dfire_recordings
    • Contains all call recordings of the connection and the foreign key connection_id to the corresponding connection.
  • dfire_inbound_calls
    • Contains all inbound calls and the foreign key contact_id to the corresponding contact

Alternativtext wenn Bild nicht gefunden

Database Connection URL Schema

MySQL / MariaDB:

mysql://username:password@localhost:3306/database?useSSL=false

PostgreSQL:

postgres://username:password@localhost:5432/database?sslmode=disable

Microsoft SQL Server:

sqlserver://username:password@localhost:1433/instance/database

Example

Transfer all transactions from 01 February 2018 in the campaign MY_CAMPAIGN to a local running instance of Microsoft SQL Server. Only updates that begin with the prefix 'fc_' or 'qc_' in campaign stages and have been performed by a user are to be transferred.

dbsync2 --a db_sync --fm hi_updates_only --fp 'fc_,qc_' --c MY_CAMPAIGN_ID --ct MY_CAMPAIGN_SYNC_CLIENT_TOKEN \
        --s 2018-02-01 --url sqlserver://my_user:my_password@localhost:1433/my_database

Web service

As an alternative to a database, the transactions can be forwarded to a web service. The service must accept POST requests and answer the successful receipt of the data with a status code between 200 and 299. Otherwise, the data will be resent (maximum 10 attempts).

The sent payload has the following JSON format:

{
    "contact":...,      
    "transaction":...,  
    "state":...,
}
  • contact
    • contains the contact details
  • transaction
    • Contains the corresponding transaction
  • state
    • new ... for a new transaction
    • updated ... When the transaction is updated (for example, the connection data is added later).

Example

Transfer all future transactions in the campaign MY_CAMPAIGN to a Webservice.

./dbsync --a webhook --c MY_CAMPAIGN_ID --ct MY_CAMPAIGN_SYNC_CLIENT_TOKEN --url 'https://example.com/api/transactions/'

(Error) protocol

  • All error messages are written directly to the console (stdout).
  • All log messages are written to /var/log/dbsync/{MY_CAMPAIGN_ID}_{MODE}_{TIMESTAMP}.log.
  • If the directory /var/log/ is locked, then the messages appear under $HOME/.dbsync/logs/{MY_CAMPAIGN_ID}_{MODE}_{TIMESTAMP}.log.

Command line options

An overview of all options can be obtained with the following command.

dbsync --help