Instructions for plugging a website into Watson Assisstant with Node-RED + WebSockets
Okie dokie, so you want to plug your website into Watson Assistant, well, here's how you can do that.
First, you'll need to set up a Node-RED server which can talk to Watson Assistant. The demo-flow.json contains a demo flow that will hook up a websockets endpoint to a Watson Assistant instance enabling you to talk to the Assistant instance with a web page.
- Copy the contents of demo-flow.json into your clipboard and then head to any Node-RED flow.
- Top right of the Node-RED UI, hit the hamburger menu and then hover over "import" and then select "clipboard" from the context menu that appears.
- In the dialog box that appears, paste the content of your clipboard and then click "import"
- A flow will appear in your workflow, click to place it, you now have a websocket connection configured to talk to Watson Assistant
- Head to your assistant workspace and find the credentials for you flow. Copy and paste them into the configuration panel for your assistant node where applicable.
Secondly, you'll need to add some code to your web page to pass messages to the websocket connection we just created. The mvp.html file contains a working demo that will plug straight into your demo. You don't need to copy the whole thing just copy the <form>
and <script>
tags and their contents into your own HTML page.
- Copy the
<form>
and<script>
tags and their contents into your own HTML page. - Replace the
NODE_RED_SERVER_HOSTNAME
value with the hostname of your own Node-RED server.
Now, whenever you submit some text in the forms <input>
field, it will be passed to Watson Conversation.