Skip to main content

Insightful Search, Node-RED, And RocketChat

This guide assumes you have already setup Insightful Search, and its prerequisites. If you haven’t, go do that now. I have guides for them:

Table Of Contents
#

Initial Setup
#

If you have all that setup, open your Node-RED web interface. This is usually done by typing in the local ip of the system its running on followed by the port:

  • Example: http://192.168.68.1.100:30001

Open the menu by clicking on the 3 lines in the top right corner.

First click on Manage Palette, then click Install. We need two nodes:

  • node-red-contrib-ollama
  • node-red-contrib-rocketchat

Search for and install both.

Click here to view the flow template you will need. If your browser shows some tabs / buttons near the top, look for one called Raw or Raw Data and click it. Then hightlight everything with CTRL + A and copy it with CTRL + C or by right clicking and selecting Copy. Check to make sure what you’re copying starts like this:

[
    {
        "id": "2bc1c0958cc4e679",
        "type": "tab",
        "label": "Insightful Search",
        "disabled": false,
        "info": "",
        "env": []
    },

If the beginning of it doesn’t look exactly like that, it isn’t in the correct format. Double check if there is a button or tab to see the raw data. If it still looks wrong try a different browser. I know Chromium will display it properly right away, so I assume Chrome will as well, but I can’t test it because my PC runs a linux based operating system and I can’t install Chrome itself. I also know that in Firefox (which is what I use) I needed to click a button at the top labeled Raw Data to see it in the correct format.

Open the Node-RED menu like before then click Import instead of Manage Palette. Copy and Paste everything from the text file into the box. BEFORE clicking import, make sure you select new flow underneath the box. If you have any other flows setup, and you don’t do this, it will overwrite the current one. Now you can click Import

Configuration
#

Now in the Node-RED sidebar click on the little gear / cog icon to open the config tab. There should be 2 nodes that need to be configured here. One for Ollama and one for RocketChat.

  • Ollama:
    • Just type in the IP and Port for your Ollama instance. If using TrueNAS for Ollama make sure you use the Host Port not the Container Port.
    • Then cick Update at the top.
  • RocketChat:
    • Type in the IP and Port for your RocketChat instance in the following format: http://YOUR_IP:PORT. Like with Ollama, if you use TrueNAS, use the Host Port.
    • We need to make a new User account for Insightful Search to post as when responding to you.
    • So now we need to open RocketChat, and go to the Admin Panel. To do that from the home page, click on the small gear / cog icon in the top right next to your profile picture. Then click Workspace.
    • Now click on the Users tab. Then New User at the top.
    • Unfortunately every account on RocketChat requires and email. Fortunately if you have a gmail account, you can use an alias for it.
      • If you don’t have a gmail, you will either need to make a new email address, or use one that you already have that isn’t being used for a RocketChat account.
      • If you DO have a gmail account, making an alias is super simple. Just add any word and a plus sign to the beginning of it.
        • Example:
          • If your gmail is: myname@gmail.com
          • Use something like: insightful+myname@gmail.com where insightful can be any word you want.
          • You don’t actually need to check or receive any emails for the account, it’s just a RocketChat requirement to have one.
    • Give the accound a name, username, and password. Click Add User at the bottom.
    • Either log out of your admin account for RocketChat or use a private browser window and login to the new account.
    • Click on the profile picture in the top right (by default it’s a colorful square with a letter in it), then go to Profile and click on the Personal Access Tokens tab.
    • Type in a name for the token (something that describes what its for, like node-red-token)
    • Make sure to click the dropdown box and choose Ignore Two Factor Authentication or the token won’t work with Node-RED
    • Click Add
    • You will see a popup with the Token and User ID
    • SAVE both of these somewhere before closing the popup. The token WILL NOT be shown again. If you lose it, you will need to make another one.
    • Back in Node-RED paste the User ID and Token into the appropriate boxes in the RocketChat config. Then click Update at the top.
    • Go back to your admin account in RocketChat and go to the Home Page. Click the plus icon in the top left and choose Channel.
    • Give it a name, then add your account and the new account you just made. Optionally, make is a private channel if you want. That way only you and the new account can access it.
    • Go to the Admin Panel again, but this time, click on the Integrations tab.
    • Click Outgoing at the top, then click New.
    • Use the following settings:
      • Event Trigger: Message Sent
      • Enabled: On / Yes
      • Name: This isn’t super important, but I named mine node-red-insightful-search
      • Channel: The name of the channel you just created. Make sure to add a # before the name so RocketChat recognizes it as a channel
        • Examples: #ChannelName or #InsightfulSearchChannel
      • Trigger Words: !>,#>
        • Copy that exactly. Unless you want to go into the Node-RED flow and change the setup yourself.
        • You can change them if you really want to, but you’re on your own then.
      • URLs: http://NODE_RED_IP:PORT/insightful-search
        • Be sure to use the correct IP and Port or it won’t work.
        • /insightful-search is the endpoint that is configured by default in the Node-RED flow.
        • If you want to change it for some reason, open Node-RED and edit the Node all the way on the left. Change the URL field to /WHATEVER_YOU_WANT then click Done.
      • Impersonate User: On / Yes
        • This is so the messages look like they’re coming from the user account you created for Insightful Search.
      • Post as: The username of the account you made for Insightful Search.
      • Click Save at the bottom when you’re done.

Done!
#

Node-RED is now setup to work with Insightful Search and RocketChat.

If you have everything else set up, you can now start using Insightful Search via RocketChat!