> For the complete documentation index, see [llms.txt](https://docs.pascom.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pascom.net/en/integrations/connector/variables-structure.md).

# Structure Examples

Learn how to map external data to system variables in the Connector.

In the **Structure** tab of the connector, the variables defined in advance [(instructions here)](/en/integrations/connector/variables-assignment.md) must now be assigned to the **system variables** of the PASCOM telephone system. Here it is now determined where the connector should transfer the imported data.

## Job title of a user in the note field of the PASCOM phonebook

In the following section we follow the example from the **Variable Assignment** and enter the job title of a user in the PASCOM phone book.

**To do this, add the lines:**

```
      "028pho_notes" : "{{{job}}}"
```

**in der Struktur:**

```
    {
      "identity": [{

        "003use_bez": "{{{displayname}}}",
        "003use_name": "{{{username}}}",
        "003use_pw": "{{{password}}}",
        "011acc_pin": "{{{pin}}}",
        "009ext_extension": "{{{phone}}}",
        "016voi_email": "{{{email}}}"          
        ,"post": {
          "phonebook": [{
            "028pho_bez" :  "{{{displayName}}}",
            "028pho_firstname" :  "{{{givenName}}}",
            "028pho_lastname" : "{{{surname}}}",
            "028pho_email" :  "{{{email}}}",
            "028pho_notes" :  "{{{job}}}"
          }]
        }
      }]
    }
```

This passes the value of the **job** variable to the **028pho\_notes** system variable, thereby populating the notes field in the phone book of a user with the job title.

With this type of mapping, imported data can be assigned individually.

## Role Assignment

In order to be able to automatically assign users with roles whilst importing, the structure will need to be expanded to accommodate role assignments. The corresponding user roles can be read from the **memberOf** variable

Under the **Variables** tab, add the following line by clicking **Add**:

**Variable:** roles

**Optional Filters:**

```
//Fill in the roles you want to filter (rolesToFilter) like this:
//array('Role1', 'Role2');          

$rolesToFilter=array();          
$output=array();

if(empty($rolesToFilter))
    return $output;

$src = $row['memberOf'];

if(!is_array($src)) {
  $src = array($src);
}

foreach($src as $group) {
  $list = explode(',', str_replace(array('[', ']', 'CN=', 'DC=', '"'), '', $group));
  foreach($list as $elem) {
    if(in_array($elem, $rolesToFilter)) {
      $output[]=$elem;
    }
  }
}

return $output;
```

The field "roles" relates to a list of roles with which the user user should be assigned. Via the "memberOf" user field, you can define the roles within PASCOM. With this code, the connector can read the membership assignments and assign them to the user roles PASCOM field.

{% hint style="info" %}
In the PHP-Variable `rolesToFilter`, enter the **source** field code and role name for which the connector should search for. All other member assignments will be ignored.\
Example: `array('Role1', 'Role2');`
{% endhint %}

**To do this, expand the following lines so:**

```
    {{#if rollen}}
      ,"user_roles": [
        {{#each rollen}}
        "{{this}}",
        {{/each}}
        "All Users"
      ],
    {{/if}}
```

**to the structure as follows:**

```
{
  "identity": [{

    "003use_bez": "{{{displayname}}}",
    "003use_name": "{{{username}}}",
    "003use_auth_method": "EXTERN",
    "011acc_pin": "{{{pin}}}",
    "009ext_extension": "{{{phone}}}",
    "016voi_email": "{{{email}}}",
  {{#if rollen}}
    ,"user_roles": [
      {{#each rollen}}
      "{{this}}",
      {{/each}}
      "default"
    ],
  {{/if}}
    "post": {
      "phonebook": [{
        "028pho_bez":       "{{{displayname}}}",
        "028pho_firstname": "{{{givenname}}}",
        "028pho_lastname":  "{{{surname}}}",
        "028pho_email":     "{{{email}}}"
      }]
    }
  }]
}
```

{% hint style="info" %}
The role "default" relates to the system role "All" which is assigned to all users.
{% endhint %}

## Import Labels

PASCOM labels can be used to display additional information within the PASCOM telephone book.

In this example, we want to save the contact's customer number to the label **Customernumber**. This label is then visible in the telephone book, within the call logs and various other caller information points.

**Add Label**

To add labels, navigate to **ACD** > **Call Labels** and click **Add**.

Select the option **Generic Label**, enter **Customer Number** as the label name and then click **Save**.

Apply all outstanding jobs in order to complete the Label addition process.

#### Modify a Connector Profile

Go to the **Variables** tab and via the **Add** button, paste the following line:

| Variable       | Source                           |
| -------------- | -------------------------------- |
| customernumber | `return $row['customerNumber'];` |

Through this modification, the Connector will save the content of the source variable "customerNumber" in the Variable "customernumber".

This variable must now be assigned to the label **Customernumber** PASCOM field via the **Structure** tab.

**To do this simply add the following line:**

```
"post": {
  "phonebook.phonebooklabel": [
    {
      "050lab_bez": "Customernumber",
      "028050pholab_value": "{{{customernumber}}}"
    }
  ]
}
```

**to the structure:**

```
{
  "phonebook": [{
    "028pho_bez" : 			"{{{displayname}}}",
    "028pho_phone" : 		"{{{phone}}}",
    "028pho_firstname" : 	"{{{givenname}}}",
    "028pho_lastname" : 	"{{{surname}}}",
    "028pho_organisation" : "{{{organisation}}}",
    "028pho_email" : 		"{{{email}}}",
    "028pho_mobile" : 		"{{{mobile}}}",
    "028pho_homephone" : 	"{{{homephone}}}",
    "028pho_fax" : 			"{{{fax}}}",
    "post": {
      "phonebook.phonebooklabel": [
        {
          "050lab_bez": "Customernumber",
          "028050pholab_value": "{{{customernumber}}}"
        }
      ]
    }
  }]
}
```

This will assign all contacts with an entered customer number value with the Call Label **Customer Number** and corresponding value.

#### Check Results

{% hint style="info" %}
Label assignments will NOT be displayed when using the "Save and Simulate" tool.
{% endhint %}

To check whether the label assignment has been successful, go to the PASCOM PBX Web-UI menu options **Users** > **Phonebook**. Select and **Edit** an appropriate user and check whether the assignment was successful under the **Labels** tab. Alternatively, you can check your results by accessing the Company Phonebook via the PASCOM Desktop App.

## Add softphone to user

In order to be able to assign a softphone to a user directly during import, the structure must be extended to include terminal assignment. Some connectors already bring an implemented solution, which can be used directly in the basic settings.

To do this, add the following line in the **Variables** tab by **Add**:

**Variable:** createSoftphone

1. **Important:** The value of the variable createSoftphone must correspond to the value **"yes"** in the source variable (or a value you define).

**To do this, add the lines:**

```
    {{#if createSoftphone}}
      ,"ipdevice.mdsoftphone": [{
        "010dev_bez": "{{username}}_softphone"
        }]
    {{/if}}
```

**to the structure:**

```
{
  "identity": [{

    "003use_bez": "{{{displayname}}}",
    "003use_name": "{{{username}}}",
    "003use_auth_method": "EXTERN",
    "011acc_pin": "{{{pin}}}",
    "009ext_extension": "{{{phone}}}",
    "016voi_email": "{{{email}}}",
  {{#if rollen}}
    ,"user_roles": [
      {{#each rollen}}
      "{{this}}",
      {{/each}}
      "default"
    ],
  {{/if}}
    "post": {
      "phonebook": [{
        "028pho_bez":       "{{{displayname}}}",
        "028pho_firstname": "{{{givenname}}}",
        "028pho_lastname":  "{{{surname}}}",
        "028pho_email":     "{{{email}}}"
      }]
    }
  }]

    {{#if createSoftphone}}
      ,"ipdevice.mdsoftphone": [{
        "010dev_bez": "{{username}}_softphone"
        }]
    {{/if}}
}
```

This will assign a softphone to each user with entered value **"yes"** in createSoftphone variable.

## Adding a Mobile Device to the User

To be able to assign a mobile device to users directly during the import, the structure must be extended to include a PASCOM mobile device. Some connectors already come with an implemented solution, which can be used directly in the basic settings.

To do this, add the following line in the **Variables** tab by clicking **Add**:

**Variable:** createMobile

1. **Important:** The value of the createMobile variable in the source variable must correspond to the value **"yes"** (or a value you define).

**Add the following lines:**

```
{{#if createMobile}}
  ,"mobile": [{
    "010dev_bez": "{{username}}_mobile",
    "010dev_caption": "{{displayname}} - mobile",
    "072mob_number": "{{mobile}}"
    }]
{{/if}}
```

**in the structure:**

```
{
  "identity": [{

    "003use_bez": "{{{displayname}}}",
    "003use_name": "{{{username}}}",
    "003use_auth_method": "EXTERN",
    "011acc_pin": "{{{pin}}}",
    "009ext_extension": "{{{phone}}}",
    "016voi_email": "{{{email}}}",
  {{#if rollen}}
    ,"user_roles": [
      {{#each rollen}}
      "{{this}}",
      {{/each}}
      "default"
    ],
  {{/if}}
    "post": {
      "phonebook": [{
        "028pho_bez":       "{{{displayname}}}",
        "028pho_firstname": "{{{givenname}}}",
        "028pho_lastname":  "{{{surname}}}",
        "028pho_email":     "{{{email}}}"
      }]
    }
  }]

    {{#if createSoftphone}}
      ,"ipdevice.mdsoftphone": [{
        "010dev_bez": "{{username}}_softphone"
        }]
    {{/if}}

    {{#if createMobile}}
    ,"mobile": [{
    "010dev_bez": "{{username}}_mobile",
    "010dev_caption": "{{displayname}} - mobile",
    "072mob_number": "{{mobile}}"
    }]
    {{/if}}
}
```

This assigns a mobile device to each user with the value **"yes"** entered in the createMobile variable.

## Assign action templates during user import

To be able to assign an action template to users directly during import, the **Identity structure** must be extended. This function is currently only limited to the **call type - after** of the action template. This applies to both **external** and **internal** telephony.

To do this, add the following line to the **Variables** tab by **Add**:

**Variable:** action\_post\_ext or action\_post\_int.

1. **Important:** The value of the variable **action\_post\_ext** or **action\_post\_int** must match the **action template name** in the source variable. (e.g. Own Voicemailbox).

**To do this, add the lines:**

```
    "action_post_ext":	"{{{action_post_ext}}}",
    "action_post_int":	"{{{action_post_int}}}",
```

**to the structure:**

```
{
  "identity": [{

    "003use_bez": "{{{displayname}}}",
    "003use_name": "{{{username}}}",
    "003use_auth_method": "EXTERN",
    "011acc_pin": "{{{pin}}}",
    "009ext_extension": "{{{phone}}}",
    "016voi_email": "{{{email}}}",
    "action_post_ext":	"{{{action_post_ext}}}",
    "action_post_int":	"{{{action_post_int}}}",
  }]
}
```

This assigns the appropriate action template to each user during import.

## Assigning users to a queue

To assign users to a queue directly during import, a new variable **"identity.queue\_membership"** must be added in the **"Post"** area. It is important to note that the queue must already exist.

To do this, insert the following line in the **Variables** tab using **Add**:

**Variable:** queue

1. **Important:** The value of the **queue** variable must correspond to the **name of the queue** in the source variable. (e.g. Sales)

**To do this, add the lines:**

```
    ,"identity.queue_membership": [
      {
        "029tea_bez": "{{queue}}",
        "011029acctea_pos": "1",
        "011029acctea_dynamic": "0",
        "011029acctea_penalty": "0"
      }          
    ]
```

**to the structure:**

```
{
  "identity": [{

    "003use_bez": "{{{displayname}}}",
    "003use_name": "{{{username}}}",
    "003use_auth_method": "EXTERN",
    "011acc_pin": "{{{pin}}}",
    "009ext_extension": "{{{phone}}}",
    "016voi_email": "{{{email}}}",
  {{#if rollen}}
    ,"user_roles": [
      {{#each rollen}}
      "{{this}}",
      {{/each}}
      "default"
    ],
  {{/if}}
    "post": {
      "phonebook": [{
        "028pho_bez":       "{{{displayname}}}",
        "028pho_firstname": "{{{givenname}}}",
        "028pho_lastname":  "{{{surname}}}",
        "028pho_email":     "{{{email}}}"
      }]
      ,"identity.queue_membership": [
      {
        "029tea_bez": "{{queue}}",
        "011029acctea_pos": "1",
        "011029acctea_dynamic": "0",
        "011029acctea_penalty": "0"
      }]
    }
  }]

    {{#if createSoftphone}}
      ,"ipdevice.mdsoftphone": [{
        "010dev_bez": "{{username}}_softphone"
        }]
}
```

This assigns the user to the corresponding queue during import.

## Fix syntax error, JSON is invalid

It can happen that during import certain characters like **", :, ,** cause a syntax error, which makes the JSON file invalid. In the following example we want to import a value in quotes (Foo):

```
{
"phonebook": [{
"028pho_bez" : "Blaa "Foo" baar test",
"028pho_phone" : "",
"028pho_firstname" : "Blaa "Foo" baar",
"028pho_lastname" : "test",
"028pho_organisation" : "",
"028pho_email" : "",
"028pho_mobile" : "",
"028pho_homephone" : "",
"028pho_fax" : "",
"011acc_id": ""
}]
}
```

**Solution:** For the variable, remove 1 of the 3 accolades (curly brackets) so that the connector no longer observes the error-causing characters. This should fix the syntax error.

**{{displayname}}** instead of {{{displayname}}}

```
    "post": {
      "phonebook": [{
        "028pho_bez":       "{{displayname}}",
        "028pho_firstname": "{{{givenname}}}",
        "028pho_lastname":  "{{{surname}}}",
        "028pho_email":     "{{{email}}}"
      }]
    }
  }]
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.pascom.net/en/integrations/connector/variables-structure.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `build a script that syncs our docs to a CMS` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
