@ikhatri Thanks for your reply. I need to find some time to understand what you are doing, but on a quick read it has many items I know I had to do, but don’t know how to, or the details of how to, your reply ticks a lot of boxes.
In the meantime I have also found the google connector written by a clever guy on the rasa gitter forum. I cannot find his name, nor find anything in gitter because its such a poor interface, which is why I am so happy this forum has started, but if he ever shows up here he will know it was credit to him.
I couldn’t get this to work, mainly because google doesn’t supply all the tokens that are included, and I couldn’t work out how to wire it all together. Perhaps this could be a starting point for a community Google Connector?
Blockquote
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 rasa_core.channels.channel import UserMessage, OutputChannel
from rasa_core.channels.rest import HttpInputComponent
logger = logging.getLogger(name)
class SlackBot(OutputChannel):
def init(self, slack_verification_token, channel):
self.slack_verification_token = slack_verification_token
self.channel = 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 = self.channel, text = text, as_user = True)
class SlackInput(HttpInputComponent):
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():
logging.info('Received new event ' )
logging.info(request.json.get('type'))
logging.info(request.json.get('action'))
logging.info(request.json.get('responseId'))
queryResult = request.json.get('queryResult')
action = queryResult.get('action')
queryText = queryResult.get('queryText')
logging.info(action)
logging.info(queryText)
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