MindStudio AI Integration

I want to use the MindStudio AI advanced embed function with Softr.

In the MindStudio embed code snippet I want to change the default “userID:” to use the Softr credentials. (see attached embed code image)

Caveat: MindStudio understands Javascript only.

In Wordpress I would use the code snippets plugin to create a compatible PHP snippet. Then I would copy the variable that gets the current userID from Wordpress and paste it into the Mindstudio embed code userID:

Now when I run Wordpress with the MindStudio AI embedded I can move
across devices and retain the threads.

Is this possible on the basic plan with Softr? How would I replicate what I’m doing with Wordpress?

Hi Jonathan,

Can you give me a link to the documentation about it?

It should be possible (basic plan, no problem = it accepts custom code)

Can you copy paste the code you took as a screenhot below my post (using the </> icon on top of the message box, when you write a message here) I will try to adapt it to your use case.

1 Like

Thanks - See below for the MindStudio embed code. I would normally replace the userId: “YOUR_USER_ID”, with the var from WP.

<script type="text/javascript">
  window.MindStudioSettings = {
    publicToken: "public_token",
    appId: "app_ID",

    // If your site/app manages its own user IDs, replace this with
    // the ID of the current user. Otherwise, delete this property.
    //
    // IF YOU DO NOT KNOW *EXACTLY* WHAT THIS MEANS, DO NOT USE THE
    // ADVANCED CONFIGURATION. If you configure this incorrectly, you
    // WILL introduce security risks for your users and end up in
    // situations where your users can see the threads and message of
    // other users.
    userId: "YOUR_USER_ID",

    // Mount the app on an iframe with a custom ID
    targetId: "mindstudio-frame",

    // Log additional debugging information to the console.
    // Disable this for production.
    debugging: true,

    options: {
      // Control whether the text input automatically focuses
      autoFocus: false,

      // If enabled, users will only be able to use a single thread
      disableThreads: false,

      // Control whether the thread panel is minimized by default
      minimizeThreadPanel: false,

      // Use launch variables to set dynamic variables that are available
      // inside your app at launch time. For example, if your site already
      // knows the user's name, you could set a variable here called
      // "userName" and then use it inside your app. Access these variables
      // in your preamble or automations with the syntax
      // {{$launchVariables->myVariable}}
      //
      // Note that these variables must be set BEFORE your app loads or
      // they will not be available.
      launchVariables: {
        myVariable: "My Value"
      }
    }
  };
</script>
<script src="https://api.mindstudio.ai/v1/embed.js"></script>
<iframe id="mindstudio-frame" referrerpolicy="origin" style="width:900px;height:600px;border:1px solid rgba(0,0,0,0.1);border-radius:8px;outline:none;" title="AI Embed" frameborder="0"></iframe>

Also what database are you using?

Will be an airtable base for the purpose of the exercise.

From 14:00 min is a demo with WP

Ok,
So what’s following should be inserted in a custom code block.
Not sure if the userId should be inside the launchVariables… (which I havent done in the script below).

In Airtable, inside the users table, add a formula field with just this inside: RECORD_ID()
Name this formula field User ID (it’s case sensitive in the script below)

<script type="text/javascript">
  let userIdField;

  if (window['logged_in_user'] && window['logged_in_user']['User ID']) {
    userIdField = window['logged_in_user']['User ID'];
  }

  window.MindStudioSettings = {
    publicToken: "pk3f1cdf5f8a7b7a4ea7faf84",
    appId: "be63afc0-dc6a-4512-8ed7-f62134",

    // Use the dynamically set userIdField as the userId
    userId: userIdField,

    // Mount the app on an iframe with a custom ID
    targetId: "mindstudio-frame",

    // Log additional debugging information to the console.
    // Disable this for production.
    debugging: true,

    options: {
      // Control whether the text input automatically focuses
      autoFocus: false,

      // If enabled, users will only be able to use a single thread
      disableThreads: false,

      // Control whether the thread panel is minimized by default
      minimizeThreadPanel: false,

      // Use launch variables to set dynamic variables that are available
      // inside your app at launch time. For example, if your site already
      // knows the user's name, you could set a variable here called
      // "userName" and then use it inside your app. Access these variables
      // in your preamble or automations with the syntax
      // {{$launchVariables->myVariable}}
      //
      // Note that these variables must be set BEFORE your app loads or
      // they will not be available.
      launchVariables: {
        myVariable: "My Value"
      }
    }
  };
</script>

<script src="https://api.mindstudio.ai/v1/embed.js"></script>
<iframe id="mindstudio-frame" referrerpolicy="origin" style="width:900px;height:600px;border:1px solid rgba(0,0,0,0.1);border-radius:8px;outline:none;" title="AI Embed" frameborder="0"></iframe>

Not sure if it works as I don’t know what you really want to perform but this is how you can retrieve the user Id within Softr:

  if (window['logged_in_user'] && window['logged_in_user']['User ID']) {
    userIdField = window['logged_in_user']['User ID'];
  }

The user Id being simply the recordId of the record of the user in Airtable.

Yep that makes perfect sense. I’ll give it a go and let you know how I get on. Much appreciated… will credit you :grinning:

1 Like

I see where you are located. I will also reach out as I may have a project for you in that location. :ok_hand:

This worked perfectly. Thankyou. I’ll be in touch with some project work in your location. Thanks again

1 Like