How to Create a Chatbot on IBM Cloud and Integrate with Slack: Part 4

1 min read

Part 4 of a four-part series. In this post, we are going to register a bot in Slack and connect to the endpoint in Node-RED.

cg1

Step 1. Create an app (bot) on Slack

  1. Go to https://api.slack.com/apps.
  2. Click Create New App, and set the name and workspace to install.
    Click Create New App, and set the name and workspace to install.
    Note: It requires an approval from the workspace admin.

Step 2. Add Slash command

  1. Once the app is created, go to Features > Slash Commands.
  2. Click Create New Command.
    Click Create New Command.
  3. Define the command detail and Save. Make sure your command does not overlap with an existing command. Then, Request URL is going to be: https://<your_node_red>/talk. This time, I've named the commands as follows:
    • /talktest for starting the conversation
    • /cleartest for clearing the current conversation
      Define the command detail and Save.
  4. Go to Basic Information and click Request to Install. Then, Save Changes. The request will go to the admin of the workspace and they need to approve it. 
    Go to Basic Information and click Request to Install. Then, Save Changes. The request will go to the admin of the workspace and they need to approve it. 

Step 3. Test the integration

Once the request is approved, we are all set. Let's initiate the conversation by entering the command. The slash command can be executed anywhere on the workspace, and the responses are only visible to you. 

  1. Enter the slash command and hit enter.
  2. In order to continue the conversation, enter the command before your input.
    In order to continue the conversation, enter the command before your input.
    In order to continue the conversation, enter the command before your input.
    In order to continue the conversation, enter the command before your input.
  3. In order to reset the conversation, execute the clear command.
    In order to reset the conversation, execute the clear command.

What's next?

Now, you know how we can create a chatbot using Watson Assistant and Node-RED. This time we integrated with Slack, but you can connect to your own apps or any other service that can access the endpoint we created on Node-RED. We hope you got the idea and apply what we've done in this series. Here are some "next steps" you can consider.

  • Node-RED visualizes the flow, but it is not suitable for production use. Switch to Node.js for better load balancing and precise controls.
  • Integrate with other services, such as text-to-speech, tone analyzer and any other nodes you can import to your Node-RED.

If you encounter any technical difficulties with services on IBM Cloud, feel free to contact at the Support Center

Disclaimer

IBM is not liable for any damages arising in contract, tort or otherwise from the use of or inability to use this post or any material contained within. All sample code is provided as-is and IBM does not support customization. Do not use the code in production. 

Be the first to hear about news, product updates, and innovation from IBM Cloud