To conduct human interaction experiments in the social sciences and behavioral research, a text chat is essential. Participants are able to communicate in a given timeframe, including a certain level of profile information.


For the different levels of information mentioned above, a varying setup is required. The Participant Variables Tab gives potential for customization of the chat. In here three variables can be defined, the color of the text (Text Color Variable Name), an avatar (Avatar Variable Name) that will be shown next to the participants messages as well as in the list of participants and a nickname (Nickname Variable Name). If no nickname is entered, the participant labels (P.1, P.2...) will be shown instead. To make all these possibilities work, the context for the related variable has to be selected and, if an option should not be used it may be disabled as well.

Interaction Chat - Participant Variables

To make these configurations work, the values for the variables need to be set within the experiment. If the Text Color Context is set to Participant Everywhere and the Text Color Variable Name is interactionTextcolor, a variable could be set through $variableApi->setPE('interactionTextcolor', 'red') in any previous step. An example for the configuration of the variables is displayed in the screenshot below. These are the values used, to get the result that are displayed in the Interaction section.

Interaction Chat - Set Values


In the Interaction Tab of the Steptype, it can be defined which participants should be interacting together in the same chat. This depends on the selected Context Type. If the Context Type Variable Value is selected, the Context Identifier Variable Name specifies the variable that defines which participants are going to interact. All participants with the same value for this variable will be in the same chat.

The Show interaction members checkbox is used to show a list of participants next to the chat. In addition, a visual effect to extend time pressure is available by using the Alert before end (s) parameter. Specifying an amount of seconds results in a signaling submit button, as shown in the screen below.

The remaining polling parameters can be kept to their default values, if not necessary otherwise. These are used to define the delay until the next request for new messages is sent to the server.

In the Chat Tab the maximum length of a single message can be defined (Message max. length). The entered value represents the amount of entered characters in a message.

Chat Example

Data Report

The data generated through chat communication is not saved in variables, unlike most of the other information in SoPHIE. Therefore, the simplechat API is provided, to retrieve data from the database. The easiest way to get a structured result of the chat communications is shown in the code below, which is applied in a plain text report.

$simplechat = $api->get('sophielabs_simplechat');


For most use cases this result is not sufficient, as the data analysis is processed on structured data accessible in csv format or similar. To get to this result, simply use the code below in a csv report.

$chatApi = $api->get('sophielabs_simplechat');

$data = array();
$data[] = array(
    'Channel Identifier',
    'Abs. Time',

$messages = $chatApi->getMessages();

$channelIdentifier = null;
foreach ($messages as $msg)
    if ($msg['channelIdentifier'] === $channelIdentifier)
        $msg['channelIdentifier'] = '';
        $channelIdentifier = $msg['channelIdentifier'];
    $data[] = array(

foreach ($data as $row)
    $line = array();
    foreach ($row as $cell)
        // $cell = str_replace(array("'", '\\', '"', "\n", "\r", "\t"), '', $cell);
        $cell = preg_replace('/\s/', ' ', $cell);
        $cell = str_replace('"', '""', $cell);
        $line[] = '"' . $cell . '"';
    echo implode(';', $line) . PHP_EOL;

These functions are not limited to reports though. The simplechat API can be used to display communication results during the experiments as well.