Integrating RASA bot with Slack

Hi All,

I am facing an issue while integrating my bot with Slack.

I am using ngrok to connect Slack with my local server. When I am sending “Hello” to my Bot, reply is not coming from slack end. But the same is working when tested from command prompt(without slack). When checked ngrok, it is showing status code as 200 (POST /webhooks/slack/webhook 200 ok) and my bot server’s console is copied below: - - [2018-11-16 16:42:19] “POST /webhooks/slack/webhook HTTP/1.1” 200 200 0.001000 C:\Users\af92874\AppData\Local\Programs\Python\Python35\lib\site-packages\sklearn\preprocessing\ DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an err or. Use array.size > 0 to check that an array is not empty. if diff: - - [2018-11-16 16:42:46] “POST /webhooks/slack/webhook HTTP/1.1” 200 115 2.662000 - - [2018-11-16 16:42:46] “POST /webhooks/slack/webhook HTTP/1.1” 201 141 0.002000

Below is the event subscription screenshot:


Python- 3.5.2 Rasa NLU - 0.13.4

Please let me know where i am going wrong.

Hey @Navankur. Are you sure your Rasa agent and ngrok are running on the same port?

Hi @Juste, Actually I got the issue, It was a blunder, While integrating with Slack, we need to provide slack_token from Oauth and Permission page, I was giving ‘OAuth Access Token’ instead of ‘Bot User OAuth Access Token’.

btw thanks for your input. :slight_smile:

1 Like

Hehe, glad the issue got solved :slight_smile:

Rasa Core version: 0.12.2 Python version: 3.6 Operating system (windows, osx, …): Windows 10 Issue: We have trained our model and the bot is giving proper output in the console. Now we have tried integrating with slack using python. We have created 2 python script. First we run The code is attached below :

from future import absolute_import from future import division from future import print_function from future import unicode_literals

import logging

from builtins import str from flask import Blueprint, request, jsonify

from import UserMessage, OutputChannel, InputChannel #from import HttpInputComponent

logger = logging.getLogger(name)

class SlackBot(OutputChannel): def init(self, slack_verification_token, channel): self.slack_verification_token = slack_verification_token = channel

def send_text_message(self, recipient_id, message):
	from slackclient import SlackClient
	text = message
	recipient = recipient_id
	CLIENT = SlackClient(self.slack_verification_token)
	CLIENT.api_call('chat.postMessage', channel =, text = text, as_user = True)

class SlackInput(InputChannel): def init(self, slack_dev_token, slack_verification_token, slack_client, debug_mode): self.slack_dev_token = slack_dev_token self.debug_mode = debug_mode self.slack_client = slack_client self.slack_verification_token = slack_verification_token

def blueprint(self, on_new_message):
	from flask import Flask, request, Response
	slack_webhook = Blueprint('slack_webhook', __name__)
	@slack_webhook.route('/', methods = ['GET'])
	def health():
		return jsonify({'status':'ok'})
	@slack_webhook.route('/slack/events', methods = ['POST'])
	def event():
		if request.json.get('type') == 'url_verification':
			return request.json.get('challenge'), 200
		if request.json.get('token') == self.slack_client and request.json.get('type') == 'event_callback':
			data = request.json
			messaging_events = data.get('event')
			channel = messaging_events.get('channel')
			user = messaging_events.get('user')
			text = messaging_events.get('text')
			bot = messaging_events.get('bot_id')
			if bot == None:
				on_new_message(UserMessage(text, SlackBot(self.slack_verification_token, channel)))
		return Response(), 200
	return slack_webhook from rasa_core.channels.slack import SlackInput from rasa_core.agent import Agent from rasa_core.interpreter import RasaNLUInterpreter import yaml from rasa_core.utils import EndpointConfig from import InputChannel

nlu_interpreter = RasaNLUInterpreter(‘./models/default/shoenlu’) action_endpoint = EndpointConfig(url=“http://localhost:5055/webhook”) agent = Agent.load(‘./models/dialogue’, interpreter = nlu_interpreter, action_endpoint = action_endpoint)

input_channel = SlackInput(‘', #app verification token '’, # bot verification token ‘*******************’) # slack verification token

agent.handle_channels([input_channel], 5004, serve_forever=True)

We run the and get the following in the console :

We parallelly run ngrok using the following command : ngrok http 5004

We use the forwarding port from it and use it in slack Event Subscription. When we send ‘hi’ to the bot using slack we get 200 status for POST but the bot does not reply back.

Content of domain file (if used & relevant):


@agrima_agarwal Hi Agrima,

Pls, check the token that you are giving to your bot from slack. Actually slack provides two different token, try using both of them one by one. I tried using ‘Bot User OAuth Access Token’ and it worked.

1 Like

I am also not getting any response from the Bot although when i send any message from Slack i can see Post request with 200 status

I ensured i am using Bot User OAuth Access Token and i also subscribed to same Bot events mentioned above.

@aggarwalrahul86 - Can u pls help me .I have similar issue.Did you able to sort your slack integration with Bot.When i check the post request at NGROK level getting response 200 status but Bot is not responding at workspace level,Kindly help.Thanks.

I had exactly the same problem. Thank you!

Looks like same issue as Message not going frm ngrok to Rasa in Slack integration

Some definitive answer with sample files would help

endpoints.yml should look like:

  url: "http://localhost:5055/webhook"

Because action_endpoint is for the actions, not for anything else, and it can run on default port 5055.

Slack -> ngrok -> Rasa server is the main message flow path. So, between rasa server and ngrok the port has to be same, say 5004. Then between ngrok and slack the url token has to be same. This how chaining/binding is done.

Another observation: Need to start rasa server on , say 5004, first, then ngrok http on 5004, then get the ngrok url token, put it in Slack Verify then only it verifies fine else it errors. Order seems important

Hello my Name is Ludiana,

I have been working on creating a chat bot using Rasa’s Framework and now I wanted to Integrate my chat bot with Slack channel. I found the steps to do so on this website however I am having trouble verifying the endpoint for receiving slack messages so that I can use it to get my slack token. I Add my Rasa request URL http://localhost:5005/webhooks/slack/webhook, and replacing the host and port with the appropriate values and even tried using ngrok but I still kept getting the following error: Error: Requested URL /webhooks/slack/webhook not found Would you please give me a pointed on how I can go about solving this issue?