in our company we have full stack developer is there way to use node js to write custom connector i am a Ai engineer and pythonist i dont know the django or flask.please help me out
hey @vigneshgig can you please explain what do you mean by custom connector?
To connect the Rasa core to any messaging platform we use inputchannel or outputchannel for example to connect the Rasa core to facebook we use inbuilt connector like that For Google’s assistant
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import logging
from flask import Flask, Response, Blueprint, request, jsonify
from rasa_core.channels.channel import UserMessage, OutputChannel
from rasa_core.channels.channel import InputChannel
from rasa_core.channels.channel import CollectingOutputChannel
import json
logger = logging.getLogger(__name__)
class GoogleConnector(InputChannel):
"""A custom http input channel.
This implementation is the basis for a custom implementation of a chat
frontend. You can customize this to send messages to Rasa Core and
retrieve responses from the agent."""
@classmethod
def name(cls):
return "google_home"
def blueprint(self, on_new_message):
google_webhook = Blueprint('google_webhook', __name__)
@google_webhook.route("/", methods=['GET'])
def health():
return jsonify({"status": "ok"})
@google_webhook.route("/webhook", methods=['POST'])
def receive():
payload = json.loads(request.data)
sender_id = payload['user']['userId']
intent = payload['inputs'][0]['intent']
text = payload['inputs'][0]['rawInputs'][0]['query']
if intent == 'actions.intent.MAIN':
message = "<speak>Hello! <break time=\"1\"/> Welcome to the Rasa-powered Google Assistant skill. You can start by saying hi."
else:
out = CollectingOutputChannel()
on_new_message(UserMessage(text, out, sender_id))
responses = [m["text"] for m in out.messages]
message = responses[0]
r = json.dumps(
{
"conversationToken": "{\"state\":null,\"data\":{}}",
"expectUserResponse": 'true',
"expectedInputs": [
{
"inputPrompt": {
"initialPrompts": [
{
"ssml": message
}
]
},
"possibleIntents": [
{
"intent": "actions.intent.TEXT"
}
]
}
]
})
return r
return google_webhook
Like this I want example for node is for office friend
I don’t know about flask or Django in our company full stack only there to create web UI Right now I m using http rest API to connect the Rasa core server with web UI it’s working but I need more roburst.so that they can change the outgoing message from the rasa core for there convenience.
And also please help me out in custom message I want to send a custom elements to web UI backend You posted a question that custom message is not getting but after you replied that you solved by other method can you tell me that method @jiteshgaikwad