Embed AI chatbots in Qualtrics surveys

An open-source platform for researchers who need to run chatbot experiments. Create a system prompt, embed an iframe in Qualtrics, and collect conversation data. Any URL parameter becomes a template variable in your prompt.

How it works

1

Write a system prompt with template variables

Use {{variable_name}} anywhere in your system prompt. These variables get replaced with values from URL parameters at runtime — including data piped directly from Qualtrics.

You are a chatbot assistant. The participant's name is {{name}}
and they work as a {{occupation}}.

{{#if persona}}Behave as a {{persona}} advisor.{{/if}}

Ask them about their experience in their field.
2

Embed in Qualtrics with URL parameters

In Qualtrics, add a question and paste this JavaScript in the question's JavaScript editor. It creates an iframe and passes participant data as URL parameters. Every parameter (except experiment_id and participant_id) becomes a template variable in your system prompt.

Qualtrics.SurveyEngine.addOnload(function () {
  var participantId = "${e://Field/ResponseID}";
  var name = "${e://Field/name}";
  var occupation = "${e://Field/occupation}";

  var iframeUrl =
    "https://chat2survey.com/chat" +
    "?experiment_id=YOUR_EXPERIMENT_ID" +
    "&participant_id=" + encodeURIComponent(participantId) +
    "&name=" + encodeURIComponent(name) +
    "&occupation=" + encodeURIComponent(occupation) +
    "&persona=friendly";

  var iframe = document.createElement("iframe");
  iframe.src = iframeUrl;
  iframe.style.width = "100%";
  iframe.style.height = "600px";
  iframe.style.border = "none";

  this.getQuestionContainer().appendChild(iframe);
});

Qualtrics replaces ${e://Field/name} and ${e://Field/occupation} with the participant's actual responses or embedded data. Those values then fill in {{name}} and {{occupation}} in your system prompt. You can pass as many parameters as you need.

3

Collect and export conversation data

View conversations in the admin dashboard. Export all data as CSV, JSON, or JSONL. Each row includes the participant ID, message role, content, and timestamp.

Details

LLM providers
OpenAI (GPT-4, GPT-4o, etc.) and Anthropic (Claude). Bring your own API key per experiment.
Template variables
Any URL parameter passed to the chat page is available as {{param_name}} in your system prompt. Supports conditional blocks with {{#if var}}...{{/if}}.
Message limits
Set a max number of messages per conversation. When the limit is reached, the chat shows a configurable completion message.
Seed messages
Configure a first message that appears before the participant types anything. Useful for setting context or giving instructions.
CORS / allowed origins
Restrict which domains can embed your chat. Typically your Qualtrics domain (e.g. stanforduniversity.qualtrics.com).
Data export
Export all conversations as CSV (one row per message), JSON (grouped by participant), or JSONL.

Feedback

This is an early-stage project. If you have questions, feature requests, or run into issues, let us know.