Embed dashboard iframe in 'end message' - needs node.js / jsonwebtoken

9 months 3 weeks ago - 9 months 3 weeks ago #171761 by redbeard

I would like to display a chart being powered by my BI tool at the end of a survey on the 'end message'.

For this, my BI tool says I have two things to do:

1) Insert this code snippet in your server code to generate the signed embedding URL - I have a choice of languages I can use:
// you will need to install via 'npm install jsonwebtoken' or in your package.json
var jwt = require("jsonwebtoken");
var METABASE_SECRET_KEY = "<secret key>";
var payload = {
  resource: { dashboard: 6 },
  params: {
    "category": "<survey ID>"
var token = jwt.sign(payload, METABASE_SECRET_KEY);
var iframeUrl = METABASE_SITE_URL + "/embed/dashboard/" + token + "#bordered=true&titled=true";

It is worth noting that: I am on a shared hosting account with SiteGround (node.js is not allowed to run) - if I need node.js I can probably install LimeSurvey on a dedicated account.

# You'll need to install PyJWT via pip 'pip install PyJWT' or your project packages file
import jwt
METABASE_SECRET_KEY = "<Secret key>"
payload = {
  "resource": {"dashboard": 6},
  "params": {
    "category": "<survey id>"
token = jwt.encode(payload, METABASE_SECRET_KEY, algorithm="HS256")
iframeUrl = METABASE_SITE_URL + "/embed/dashboard/" + token.decode("utf8") + "#bordered=true&titled=true"

2) Then insert this code snippet in your HTML template or single page app.

I have tried uploading the code from 1 as a javascript file in a theme I extended (see capture.png, attached)

And the end message looks like:
<iframe allowtransparency="" frameborder="0" height="600" src="iframeUrl" width="800"></iframe>

Attached in capture2.png is the error message when I run the survey and reach the 'end page'
Last edit: 9 months 3 weeks ago by redbeard. Reason: Add screenshot of error message + detail

Please Log in or Create an account to join the conversation.

LimeSurvey Partners

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!