Working with surveys

TrueConfAbout 7 min

Working with Surveys

For each server notification (request), the client should respond as follows:

{
    "type": 2,
    "id": 123456
}

Once the response is sent, the user’s message is marked as read by the bot and a check mark appears in the TrueConf client application.

Client Requests

Send survey

Allows you to send an already created survey to the chat. The survey must be created in advance using one of the following methods:

  • through the personal area TrueConf Server;
  • in the client application TrueConf;
  • using API v4 available in version TrueConf Server 5.5.3.

Request:

{
    "type": 1,
    "id": 5,
    "method": "sendSurvey",
    "payload": {
        "chatId": "5abba630dd1089090ba41c69c7aa34e4ba277a43",
        "replyMessageId": "267d61f2-2ba1-4e88-83ab-bb84415f31b6",
        "content": {
            "url": "https://server.url/webtools/survey",
            "appVersion": 1,
            "path": "employee_testing",
            "title": "Employee survey",
            "description": "{{Survey}}",
            "buttonText": "{{Go to survey}}",
            "secret": "25690753a489f037af09b5cbce417b41374807fe",
            "alt": "📊 <a href='https://server.url/webtools/survey?id=employee_testing&error=autologin_not_supported'>Employee survey</a>"
        }
    }
}

ParameterTypeMandatoryDescription
typeuint32YesMessage type (default is 1). Corresponds to MESSAGE_TYPE.REQUEST
iduint32YesUnique request identifier. An incrementable value assigned by the sender, mandatory in each request for subsequent association with the response. Read more here.
methodstringYesCommand sendSurvey
chatIdstringYesChat ID for sending a poll
replyMessageIdstringNoMessage ID, if this is a response
urlstringYesThe survey URL on the server is in the format https://server.name/webtools/survey.
appVersionnumberYesSurveys version on the server
pathstringYesSurvey campaign ID
titlestringYesSurvey Title
descriptionstringYesSurvey type — anonymous or non-anonymous. Always contains the string \{\{Anonymous survey\}\} or \{\{Survey\}\}.
buttonTextstringYesThe text displayed on the button to proceed to the survey. Always contains the string \{\{Go to survey\}\}.
secretstringYesA random string from the message body. It should be generated as a SHA1 hash from the concatenation of the poll name and an arbitrary string.
altstringYesAlternative link to access the survey. It appears as: 📊 <a href="<url>?id=<path>"><title></a>, where <url>, <path>, and <title> are replaced with the corresponding values.

Response:

{
    "type": 2,
    "id": 5,
    "payload": {
        "timestamp": 1750168761373,
        "messageId": "f8865b5c-877c-4a55-b175-a667ebf5f007",
        "chatId": "5abba630dd1089090ba41c69c7aa34e4ba277a43"
    }
}
ParameterTypeMandatoryDescription
typeuint32YesMessage type (default is 2). Corresponds to MESSAGE_TYPE.RESPONSE
iduint32YesAn identifier matching the number sent in the original request, used to link the request and response.
chatIdstringYesChat ID to which the message was sent
messageIdstringYesMessage ID. This ID can be used later for modifying, forwarding, or deleting the message.
timestampuint64YesTimestamp of message sent in UNIX timestamp format with millisecond precision

In the event of an error, a message containing the errorCode parameter is returned. A list of possible values is available in the corresponding section of the documentation.

Edit survey

Request:

{
    "type": 1,
    "id": 1,
    "method": "editSurvey",
    "payload": {
        "messageId": "f8865b5c-877c-4a55-b175-a667ebf5f007",
        "content": {
            "path": "employee_testing_marketing",
            "title": "Employee survey of the Marketing department",
            "description": "{{Survey}}",
            "buttonText": "{{Go to survey}}",
            "alt": "📊 <a href='https://server.url/webtools/survey?id=employee_testing&error=autologin_not_supported'><title></a>"
        }
    }
}
ParameterTypeMandatoryDescription
typeuint32YesMessage type (default is 1). Corresponds to MESSAGE_TYPE.REQUEST
iduint32YesUnique request identifier. An incremental value assigned by the sender, required in each request for subsequent association with the response. Read more here.
methodstringYesThe editSurvey command
messageIdstringYesPoll message ID
pathstringYesSurvey campaign ID
titlestringYesSurvey Title
descriptionstringYesSurvey type — anonymous or non-anonymous. Always contains the string \{\{Anonymous survey\}\} or \{\{Survey\}\}.
buttonTextstringYesText that will be displayed on the button to proceed to the survey. Always contains the string \{\{Go to survey\}\}.
altstringYesAlternative link to access the survey. It appears as: 📊 <a href="<url>?id=<path>"><title></a>, where <url>, <path>, and <title> are replaced with the corresponding values.

Response:

{
    "type": 2,
    "id": 1,
    "payload": {
        "messageId": "f8865b5c-877c-4a55-b175-a667ebf5f007",
        "timestamp": 1735314170572
    }
}
ParameterTypeMandatoryDescription
typeuint32YesMessage type (default is 2). Corresponds to MESSAGE_TYPE.RESPONSE
iduint32YesAn identifier matching the number sent in the original request, used to link the request and response.
messageIdstringYesEdited message ID
timestampuint64YesTimestamp of the message edit in UNIX timestamp format with millisecond precision.

In the event of an error, a message containing the errorCode parameter is returned. A list of possible values is available in the corresponding section of the documentation.

Server Notification

New survey

When a new survey is sent in the chat, the client will receive a corresponding notification from the server.

Notification from the server:

{
    "method": "sendMessage",
    "type": 1,
    "id": 11,
    "payload": {
        "chatId": "bd05af54347e04a1c44e70033d35834d4428bb5d",
        "messageId": "d66254de-9d89-4130-8027-c5378f042800",
        "timestamp": 1746029007569,
        "author": {
            "id": "brown@video.example.com",
            "type": 1
        },
        "isEdited": false,
        "box": {
            "id": 4,
            "position": "0"
        },
        "type": 204,
        "content": {
            "url": "<tool_url>?id=...&k=...&mode=popup&call_id=vasya@srv.trueconf.name/1vca3&lang=ru&version=1&app=TrueConf+WebClient&dn=Vasiliy&s=12fee56062786c267cc286045f1fac76",
            "appVersion": 1,
            "path": "some_survey",
            "title": "Meeting survey",
            "description": "{{Survey}}",
            "buttonText": "{{Go to survey}}",
            "secret": "054c1cf18f1e64f4c38b256effedfe18debdcbba",
            "alt": "📊 <a href='https://server.url/webtools/survey?id=some_survey&error=autologin_not_supported'>Meeting survey</a>"
        }
    }
}

The notification about a poll message contains fields corresponding to the Envelope objects. A detailed description of these fields can be found in the section dedicated to working with messages and polls.

Response from client:

{
    "type": 2,
    "id": 123456
}
FieldTypeMandatoryDescription
typeuint32YesMessage type (default is 2). Corresponds to MESSAGE_TYPE.RESPONSE
iduint32YesMessage ID being replied to (see more)