Add in-app support to a C or C++ app (Qt)
Give your C, C++ or Qt desktop app a "Get help" button that shares your app's window with your support team, with consent, in your own name, colour and logo.
Give your desktop app a "Get help" button: your customer clicks it and agrees, and your support team sees your app's window in the GaiaDesk console — and, if you allow it, guides it — without the customer installing anything.
GaiaDesk's C and C++ SDK works with any toolkit — Qt, Win32, Cocoa, GTK — on macOS, Windows and Linux. It comes in two parts: the C API of the native library (gaiadesk_embed.h), and a header-only C++17 wrapper (gaiadesk/embed.hpp) with typed options and events and an RAII session. The wrapper and the CMake files are open source (MIT), at github.com/Gaia-Desk/gaiadesk-embed-cpp. They wrap the same signed native library, libgaiadesk_embed, as GaiaDesk's other embed SDKs; the library is a prebuilt binary that ships, unmodified, beside your app. For how in-app support fits together, see In-app support.
What your customer sees
One button. Your app shows "Get help" wherever you put it.
A consent dialog in your colours. It names your company, says what will be shared (this app's window, or the screen if you chose it) and whether your team will be able to guide it. Nothing is shared until the customer agrees. It is attached to the window that asked (a sheet on macOS, an owned window on Windows), never behind it. For a live preview, choices, who is waiting and a stored receipt, use the consent step.
An indicator for as long as anything is shared. "Sharing with Acme · Stop sharing", drawn by the library on top of your app. Your app cannot hide it. In a guided session it also has Pause control. While the customer waits for an agent it offers Cancel instead, and your customer can drag it anywhere (see The indicator).
A support code. Nine digits your customer can read to an agent over the phone.
When the session ends — the customer presses Stop sharing, your app stops it, the session expires, or the app quits — sharing stops at once and nothing is left behind: the library installs nothing, runs no service and writes nothing to disk.
What your support team sees
Agents open Support in the GaiaDesk console, see the waiting customer (with the details your backend passed) and join, or type the support code. Only your own account and team can join, and only team members with a support seat.
1. Add the SDK
With CMake (3.18 or later), fetch it in your CMakeLists.txt:
include(FetchContent)
FetchContent_Declare(gaiadesk_embed
GIT_REPOSITORY https://github.com/Gaia-Desk/gaiadesk-embed-cpp.git
GIT_TAG v0.4.0)
FetchContent_MakeAvailable(gaiadesk_embed)
target_link_libraries(my_app PRIVATE GaiaDesk::embed)
gaiadesk_embed_deploy(my_app)The C++ wrapper needs C++17 or later in your target (target_compile_features(my_app PRIVATE cxx_std_17)); the C header needs nothing.
Not using CMake? Download the release archive for your platform from the repository's latest release, check it against the .sha256 beside it, add its include/ to your include path and link the library (-lgaiadesk_embed, or gaiadesk_embed.dll.lib with MSVC). An unpacked archive also works with find_package(GaiaDeskEmbed).
Platform | Archive |
|---|---|
macOS (universal) |
|
Windows x64 |
|
Linux x86_64 (glibc) |
|
2. The native library
At configure time, FetchContent downloads the archive for the platform you build for from the repository's release, and refuses it unless its SHA-256 matches the hash pinned in cmake/FetchGaiaDeskEmbed.cmake; nothing is unpacked on a mismatch. -DGAIADESK_EMBED_ROOT=<dir> uses an archive you have already unpacked instead, and -DGAIADESK_EMBED_BASE_URL=<url> downloads from a mirror, still checked against the pinned hashes.
gaiadesk_embed_deploy(my_app) copies the library beside your executable after every build and sets its RPATH:
macOS:
libgaiadesk_embed.dylibgoes in your bundle'sContents/Frameworks(RPATH@executable_path/../Frameworks), so it is signed with your app.Windows:
gaiadesk_embed.dllsits beside your.exe. It needs the Visual C++ runtime (VCRUNTIME140.dll), which most apps already ship.Linux:
libgaiadesk_embed.sosits beside your executable (RPATH$ORIGIN). It needslibgbm1,libwayland-client0andlibxcb1.
Your install rules are your own: install the same file to the same place relative to your installed executable.
3. Create sessions on your backend
Your server decides who may get help. It creates the support session with a secret API key (scope support) and hands the app only its embed token:
curl -s -X POST https://api.gaiadesk.net/v1/support/sessions \
-H "Authorization: Bearer $GAIADESK_API_KEY" -H "Content-Type: application/json" \
-d '{"mode": "view", "customer": {"name": "Ada", "plan": "pro"}}'The response carries embed_token (gdemb_…), which your app passes on as Options::embed_token. mode is view (look only) or cobrowse (see Guided sessions).
Never ship the secret key in your app: the embed token is all it needs. The full request is in the support API reference.
4. Add the button
A complete Qt 6 Widgets app:
#include <QApplication>
#include <QLabel>
#include <QLineEdit>
#include <QMessageBox>
#include <QPointer>
#include <QPushButton>
#include <QVBoxLayout>
#include <QWidget>
#include <gaiadesk/embed.hpp>
#if defined(Q_OS_MACOS)
#include <gaiadesk/embed_macos.hpp>
#elif defined(Q_OS_WIN)
#include <gaiadesk/embed_win32.hpp>
#endif
namespace ge = gaiadesk::embed;
class HelpWindow : public QWidget {
public:
HelpWindow() {
auto* col = new QVBoxLayout(this);
token_ = new QLineEdit(this); // the embed token, from your backend
auto* help = new QPushButton("Get help", this);
status_ = new QLabel(this);
col->addWidget(token_);
col->addWidget(help);
col->addWidget(status_);
connect(help, &QPushButton::clicked, this, [this] { getHelp(); });
}
~HelpWindow() override { session_.stop(); } // before the widgets its events update go away
private:
void getHelp() {
if (session_.active()) return;
// 1. Ask: the library's dialog (macOS, Windows), or your own (Linux).
std::optional<bool> agreed = ge::request_consent("Acme");
if (!agreed)
agreed = QMessageBox::question(this, "Share this window with Acme support?",
"Acme support will see this window, not the rest of your screen. "
"You can stop at any time.") == QMessageBox::Yes;
if (!*agreed) return;
// 2. Start with the answer.
ge::Options o;
o.embed_token = token_->text().trimmed().toStdString();
o.company = "Acme";
o.window_id = windowId();
QPointer<HelpWindow> self(this);
auto started = ge::Session::try_start(
o, /*consent_granted=*/true, [this](const ge::Event& e) { onEvent(e); },
// 3. Events come on the library's threads: run the handler on the UI thread.
[self](std::function<void()> f) {
if (self) QMetaObject::invokeMethod(self, std::move(f), Qt::QueuedConnection);
});
if (!started) {
status_->setText(QString::fromStdString("Could not start: " + started.error().code));
return;
}
session_ = std::move(started).value();
}
void onEvent(const ge::Event& e) {
if (auto c = std::get_if<ge::CodeEvent>(&e))
status_->setText(QString::fromStdString("Your support code is " + c->code));
else if (std::holds_alternative<ge::EndedEvent>(e))
session_ = ge::Session(); // the session is over: free it
}
std::optional<std::uint64_t> windowId() const {
#if defined(Q_OS_MACOS)
return ge::macos::window_id_of_nsview(reinterpret_cast<void*>(winId())); // an NSView*
#elif defined(Q_OS_WIN)
return ge::win32::window_id(reinterpret_cast<HWND>(winId()));
#else
return static_cast<std::uint64_t>(winId()); // the X11 window
#endif
}
ge::Session session_;
QLineEdit* token_;
QLabel* status_;
};
int main(int argc, char** argv) {
QApplication app(argc, argv);
HelpWindow w;
w.show();
return app.exec();
}consent_granted must be your customer's answer to a consent dialog, the library's or your own: without it the library refuses with consent_required. Prefer exceptions? Session::start throws ge::Error (with code() and message()) where try_start returns a Result. A Session is move-only, and destroying it stops sharing. Without a Post function, your handler runs on the library's own threads: don't block there and don't touch UI.
Event | |
|---|---|
|
|
| the session is up; |
| an agent joined (their email, when known) / left |
| guided input paused ( |
| an agent's request and what became of it |
| e.g. |
| the customer dragged the indicator: keep it for |
|
|
| a type newer than this wrapper |
Event gained three alternatives in 0.4.0 (the consent events below): an exhaustive std::visit needs cases for them.
On macOS the app's main run loop must be running while a session is up (the indicator lives there), as it is in any Cocoa, Qt or other GUI app.
From C
#include <gaiadesk_embed.h>
#include <stdio.h>
static void on_event(void *user_data, const char *event_json) {
/* On the library's threads: hand it to your UI thread, don't block. */
(void)user_data;
printf("%s\n", event_json);
}
/* config_json: {"embed_token":"gdemb_…","consent_granted":true,"company":"Acme"} */
GdEmbed *get_help(const char *config_json) {
/* 1 agreed, 0 declined, -1 no native dialog (ask with your own), -2 wrong thread */
if (gd_embed_show_consent("Acme", "window", 0) != 1) return NULL;
GdEmbedCallbacks cb = { on_event, NULL };
GdEmbed *help = gd_embed_start(config_json, cb);
if (!help) fprintf(stderr, "refused: %s\n", gd_embed_last_error()); /* {"code":…,"message":…} */
return help; /* gd_embed_stop(help) ends the session and frees it */
}consent_granted must be literally true, and only after your customer agreed. gd_embed_last_error() is per thread: read it right after the call that failed.
The consent step (recommended)
Use the library's consent step, consent(ConsentStepOptions) / gd_embed_consent (SDK and libgaiadesk_embed 0.4.0, in gaiadesk/embed_consent.hpp, which gaiadesk/embed.hpp includes), rather than consent_granted = true after a dialog of your own. It gives you, with no UI to build:
a live preview of exactly what support will see, masked fields already black;
per-session choices for the customer: allow click-and-type or keep it view-only, share app logs, one window or the whole screen (each only when you offer it);
who is waiting and for how long, links to your privacy policy and terms, and an optional auto-decline timeout;
a consent receipt (who agreed to what, when, to which wording, hashed), stored on the session and shown in the console (see Proof of consent);
wording localized into 14 languages (or your own), and an accessible dialog: keyboard only, Enter accepts, Esc declines, screen reader names, reduced motion. macOS, Windows and Linux (X11 / XWayland).
ge::ConsentStepOptions c;
c.company = "Acme";
c.guided = true; // you want click-and-type; they may say no
c.choices = ge::ConsentOffers{true, true, std::nullopt}; // offer guided, offer logs
c.theme = ge::ConsentTheme{};
c.theme->accent = "#0f766e";
c.privacy_url = "https://acme.example/privacy";
c.server = "https://gaiadesk.net"; c.embed_token = token; c.session_id = sessionId; // the library posts the receipt
auto r = ge::try_consent(c, [](const ge::Event& e) { /* ConsentShownEvent, ConsentAcceptedEvent / ConsentDeclinedEvent */ });
if (!r) { /* bad_config (no dialog shown), wrong_thread (macOS) */ }
else if (r->accepted()) help = ge::Session::start(o, *r, onEvent, post);
// declined / timeout: the receipt says so and the request leaves the queue
// unavailable: no dialog here, ask with your own UI and pass its answer to record_consentSession::start(options, decision, …) is start(apply_consent(options, decision), …): the decision's consent_token and consent_receipt go with the join (also Options::consent_token / consent_receipt), capture becomes the customer's and guided stays on only if they allowed it. A session the consent step says no to ends with customer_declined or consent_timeout.
C++ | C | |
|---|---|---|
|
| the dialog → a |
|
| the same picture ( |
|
| your own UI's answer (decision, choices, the strings you showed) → the same |
Events to consent()'s handler: ConsentShownEvent{locale, wording_version}, ConsentAcceptedEvent{choices}, ConsentDeclinedEvent{reason} (declined or timeout). show_consent is unchanged. Capture moved to gaiadesk/embed_events.hpp (same name).
Your name, colour and logo
company puts your name on the consent dialog and on the "Sharing with Acme · Stop sharing" indicator. Add your colour and logo to the Options, and pass ConsentOptions to show_consent for the dialog in your look:
// logo_base64: your PNG (at most 256 KiB), base64-encoded
ge::ConsentOptions c{"Acme", ge::Capture::window, false, "#0f766e", logo_base64};
if (ge::show_consent(c) != ge::Consent::agreed) return; // Linux: Consent::no_native_dialog, ask yourself
ge::Options o;
o.embed_token = token;
o.company = "Acme";
o.brand_color = "#0f766e";
o.logo_png_base64 = logo_base64;
| |
|---|---|
| "Sharing with Acme": one line, at most 48 characters. Default: "Support". |
| Accent colour, |
| A PNG, at most 256 KiB, as base64. |
From C, gd_embed_show_consent_ex takes the same keys as JSON ({"company":"Acme","brand_color":"#0f766e"}), and gd_embed_start takes brand_color and logo_png_base64 in its config. A colour or logo the library refuses shows no dialog: show_consent throws ge::Error (bad_config) rather than reading it as a decline. Colour and logo need version 0.2.0 or later of the library; SDK 0.4.0 fetches library 0.4.0.
The indicator
The library places the consent dialog and the indicator by the window that asked for help:
void* win = reinterpret_cast<void*>(widget->window()->winId()); // HWND; on macOS an NSView*, so:
// win = ge::macos::nswindow_of_nsview(win); (gaiadesk/embed_macos.hpp)
ge::ConsentOptions c{"Acme"};
c.masked = true; // the dialog says private fields stay hidden (you pass masks)
c.parent_window = win; // a sheet on it (macOS) / owned by it (Windows), never behind it
ge::Options o;
o.parent_window = win; // the indicator keeps clear of it
o.indicator_position = ge::IndicatorPosition::bottom_right;
if (saved) o.indicator_origin = ge::Point{saved->x, saved->y}; // where the customer left itFrom C the same keys go in the JSON: parent_window (the NSWindow* or HWND as an integer), indicator_position (top-left, top-right (default), bottom-left, bottom-right) and indicator_origin ({x,y}).
When the customer drags the indicator you get IndicatorMovedEvent{x, y} ({"type":"indicator_moved","x":…,"y":…} in C): keep it (the library writes nothing to disk) and pass it back as indicator_origin next time; it is used while it still fits on a screen. Until an agent is admitted the indicator offers Cancel: it ends the session with customer_cancelled (as does stop() then), the request leaves your support queue at once, and that is also the session's end_reason in the API and in webhooks.
Guided sessions
By default your team can only look. To let them click and type, create the session as cobrowse (mode: "cobrowse") and set guided = true in the Options — both ends must want it. Pass the same guided to the consent dialog, so it says so. Their input is delivered inside your app's own process, only to your app's windows, only while your app is in front, never under a mask, and at most 20 actions a second. Your customer can pause it at any time from the indicator; your app can too (set_paused(true)). Every request arrives as an ActionEvent, with a reason when it was not applied (view_only, control_paused, rate_limited, not_focused, outside_app, masked, unsupported). Linux is view-only.
Keeping things private
Your app's window only. By default (
capturewindow) the library shares one window:window_id, or your app's frontmost.window_idmust be a window of your own process. Other apps, notifications and the desktop are never captured, unless you choosescreen.Masks. Mark anything sensitive — card numbers, balances, passwords — as a masked rect. It is painted black before a frame is encoded. Pass the rects you already know in
Options::masks: only start-time masks are guaranteed to cover the very first frame.set_mask_rects(gd_embed_set_mask_rects) replaces them afterwards, and an empty list clears them; send them again when your layout changes, the window is resized, or it moves to another display. At most 64 rects. If the window cannot be located, the whole picture is blacked out.Consent every time. The library refuses to start without it; there is no setting that skips the dialog or hides the indicator. Unknown config keys are refused (
bad_config).
Mask rects are relative to the top-left corner of the shared window's frame:
Units | From a widget | |
|---|---|---|
macOS | points, title bar included | content-view coordinates plus the content area's offset in the frame (Qt: |
Windows |
|
|
Linux | X11 pixels | logical × |
The repository's examples/qt-helpdesk does all three.
What each platform supports
Capture | Guided input | Consent dialog | |
|---|---|---|---|
macOS 12.3 or later (universal: Apple silicon and Intel) | window, app, screen | yes | native, branded |
Windows x64 | window, app (your focused window), screen | yes | native, branded |
Linux x86_64 (X11) | window, app (your focused window), screen (the primary screen) | view-only | the consent step (X11 / XWayland); |
macOS: your app needs the Screen Recording permission; macOS asks your customer the first time a session starts. Call the consent dialog on the main thread (elsewhere it returns
wrong_thread).Windows: nothing to install; the library needs the Visual C++ runtime most apps already ship.
Linux: the consent step's dialog runs on X11 and XWayland (on Wayland without XWayland it answers
unavailable).show_consenthas no native dialog there (request_consentreturnsstd::nullopt): use the consent step, or show your own, in your look, and pass its answer tostart. Pass the X11 window id (Qt on xcb:winId()).
What is and is not permitted
You may: ship the prebuilt library unmodified inside your app, with its licence in your app's notices; offer support sessions to your own customers; brand the dialog and indicator with your name, colour and logo.
You may not: modify, decompile or re-sign the library separately from your app; hide or imitate the indicator; start a session without your customer's agreement.
The headers, CMake files and examples are MIT; the native library and its C header are under the GaiaDesk Native Binary Licence (LICENSE-BINARY). See the SDK's README for every option, event and error code.