Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Sv translation
languageen

Introduction

The IVR Object CRM+ Query is used to query the CRM+ system using the REST API.

The queries which are used are very generic and involve writing actual SQL statements. 

The advantage is that you can retrieve just about anything.

However, it does involve a little exploratory work finding out how the database is structured first.

Postman

In order to find out what tables and fields are available, we have provided a postman collection, which can be downloaded here. This simplifies testing greatly.

Collection Download

View file
nameCRM+.postman_collection.json
height250

Variables

First of all, edit the collection, and setup the required variables. These are the settings you retrieved in this step here: CRM+ First Steps.

You will need to modify the variables:

  • accessKey (from the CRM+ account)
  • userName (the login name of the CRM+ account)
  • baseURL (the URL of your CRM+ instance)

Image Modified

Functions

The postman collection provides the following functions:

Image Modified

Scripts

The postman collection contains scripts, which parse the result and update variables in the collection so the next function can execute.

The scripts can be found in the tests section:

Image Modified

Exploring the Structure of CRM+

Retrieving all Table Names

To retrieve all table names, you will need to execute the REST functions:

  • 1. Getchallenge
  • 2. Login
  • 3. Listtypes

This will give you a JSON result containing all of the table names you can access.

For example:

Code Block
{
    "success": true,
    "result": {
    "types": [
        "Leads",
        "Accounts",
        "Contacts",
        ...

Finding out the Field Names

The simplest way to find out all the field names in a particular table is to execute a SELECT * FROM <TableName>; query.

The sample query does this on the Contacts table.

To run this in Postman execute the following functions:

  • 1. Getchallenge
  • 2. Login
  • 4. Query

Practical Queries

Obviously a practical query will depend entirely on what you are trying to achieve.

For example, to retrieve all contacts with a particular telephone number, you might do this:

Code Block
# Find a contact by telephone number
SELECT * FROM Contacts WHERE phone = '%2B$caller';

Note, the plus sign is encoded as %2B. Here we use the variable $caller, which contains the caller ID without a plus in fully qualified E.164 format, to pass in the caller number to the CRM system.

Building URLs

IDs in CRM+

CRM+ returns IDs in the REST API using a combination of the Module in which the record is hosted, and the ID itself.

For example:

Image Modified

This record is in module 4, and has ID 9.

The module can be retrieved with the function 3. Listtypes.

Here is the snippet returned by the contacts module:

Image Modified

Extracting the Record ID Only

In the jtel IVR script editor, This involves extracting the right hand side of the id, which can be achieved using the Word function in the string functions documented here: String functions

Building the URL

Building an URL for use in the jtel system involves the following components:

ComponentContents
baseURLThe base URL of the CRM+ instance.
moduleThe name of the module in which the record is present.
IDThe ID of the record without the module prefix.

The URL has the following format:

Code Block
{{baseURL}}/index.php?action=DetailView&module={{module}}&record={{ID}}

For example, to display the contact with ID 1234, the following URL could be used:

Code Block
https://mycompany.brain-app.com/index.php?action=DetailView&module=Contacts&record=1234


Sv translation
languagede

Einführung

Das IVR-Objekt CRM+ Query wird verwendet, um das CRM+-System über die REST-API abzufragen.

Die Abfragen, die verwendet werden, sind sehr generisch und benötigen das Coden von tatsächlichen SQL-Anweisungen. 

Der Vorteil ist, dass Sie so gut wie alles abfragen können.

Es erfordert jedoch ein wenig Vorarbeit, um herauszufinden, wie die Datenbank strukturiert ist.

Postman

Um herauszufinden, welche Tabellen und Felder vorhanden sind, haben wir eine Postman-Collection bereitgestellt, die hier heruntergeladen werden kann. Dies vereinfacht das Testen erheblich.

Collection Download

View file
nameCRM+.postman_collection.json
height250

Variablen

Bearbeiten Sie zunächst die Sammlung, und richten Sie die erforderlichen Variablen ein. Dies sind die Einstellungen, die Sie in diesem Schritt hier abgerufen haben: CRM+ First Steps.

Sie müssen folgende Variablen ändern:

  • accessKey (vom CRM+ Konto)
  • userName (der Anmeldename des CRM+-Kontos)
  • baseURL (die URL Ihrer CRM+-Instanz)

Image Added

Funktionen

Die Postman-Collection bietet die folgenden Funktionen:

Image Added

Skripte

Die Postman-Collection enthält Skripte, die das Ergebnis parsen und Variablen in der Sammlung aktualisieren, damit die nächste Funktion ausgeführt werden kann.

Die Skripte finden Sie im Abschnitt tests:

Image Added

Erkunden der Struktur von CRM+

Abrufen aller Tabellennamen

Um alle Tabellennamen abzurufen, müssen Sie die REST-Funktionen ausführen:

  • 1. Getchallenge
  • 2. Login
  • 3. Listtypes

Dadurch erhalten Sie ein JSON-Ergebnis, das alle Tabellennamen enthält, auf die Sie zugreifen können.

Zum Beispiel:

Code Block
{
    "success": true,
    "result": {
    "types": [
        "Leads",
        "Accounts",
        "Contacts",
        ...

Ermitteln der Feldnamen

Der einfachste Weg, alle Feldnamen in einer bestimmten Tabelle herauszufinden, besteht darin, eine SELECT * FROM <Tabellenname>; Abfrage auszuführen.

Die Beispielabfrage tut dies für die Tabelle "Contacts".

Um diese in Postman auszuführen, führen Sie die folgenden Funktionen aus:

  • 1. Getchallenge
  • 2. Login
  • 4. Query

Praktische Abfragen

Eine praktische Abfrage hängt natürlich ganz davon ab, was Sie erreichen wollen.

Um z. B. alle Kontakte mit einer bestimmten Telefonnummer abzurufen, könnten Sie dies tun:

Code Block
# Find a contact by telephone number
SELECT * FROM Contacts WHERE phone = '%2B$caller';

Beachten Sie, dass das Pluszeichen als %2B kodiert ist. Hier verwenden wir die Variable $caller, die die Anrufer-ID ohne Pluszeichen im vollqualifizierten E.164-Format enthält, um die Anrufernummer an das CRM-System zu übergeben.

URLs erstellen

IDs in CRM+

CRM+ gibt IDs in der REST-API unter Verwendung einer Kombination aus dem Modul, in dem der Datensatz gespeichert ist, und der ID selbst zurück.

Zum Beispiel:

Image Added

Dieser Datensatz befindet sich in Modul 4 und hat die ID 9.

Das Modul kann mit der Funktion 3. Listentypen abgerufen werden.

Hier ist das Snippet, das vom Modul "Contacts" zurückgegeben wird:

Image Added

Nur den Datensatz-ID extrahieren

Im jtel IVR-Skript-Editor muss dazu die rechte Seite der ID extrahiert werden, was mit der Word-Funktion in den hier dokumentierten String-Funktionen erreicht werden kann: String-Funktionen

Aufbau der URL

Der Aufbau einer URL für die Verwendung im jtel System umfasst die folgenden Komponenten:

Extracting the Record ID Only

In the jtel IVR script editor, This involves extracting the right hand side of the id, which can be achieved using the Word function in the string functions documented here: String functions

Building the URL

Building an URL for use in the jtel system involves the following components:


Contents
baseURLDie Basis-URL der CRM+-Instanz.
moduleDer Name des Moduls, in dem der Datensatz vorhanden ist.
IDDie ID des Datensatzes ohne das Modulpräfix.

Die URL hat folgenden Format:

Code Block
{{baseURL}}/index.php?action=DetailView&module={{module}}&record={{ID}}

Um z. B. den Kontakt mit der ID 1234 anzuzeigen, könnte die folgende URL verwendet werden:

Code Block
https://mycompany.brain-app.com/index.php?action=DetailView&module=Contacts&record=1234