Deploy Rasa with custom Widget/Website

Hello dear Rasa community,

I want to host my Rasa-Bot on a Debian server. For this I have written a java script file. However, I do not know how to change the endpoints, credentials, java script files that the bot also runs on the server.

Excerpt from the JS file:

function send(message) {

console.log("User Message:", message)
$.ajax({
	url: 'http://localhost:5005/webhooks/rest/webhook'
	type: 'POST',
	contentType: 'application/json',
	data: JSON.stringify({
		"message": message,
		"sender": "Me"
	}),
	success: function (data, textStatus) {
		if(data != null){
				setBotResponse(data);
		}
		console.log("Rasa Response: ", data, "\n Status:", textStatus)
	},
	error: function (errorMessage) {
		setBotResponse("");
		console.log('Error' + errorMessage);

	}
});

}

Is there a step by step guide to host a Costum widget on your own website?

Thank you very much.

@timon.su Well, I don’t know about AJAX, but are you familiar with rasa botfront? yes or no?

@nik202 Unfortunately not :confused:

@timon.su that will be more easy to integrate with your website, can I ask what is your website platform like Wordpress, Wix, duda etc?

@nik202 So the case is that we had to write a costum Website. The Website shows just a header and a footer and otherwise we created a chat widget/frame in the center to show the conversation. The HTML and CSS Code is Costum and we did not use any framework. The bot used to work fine with the website hostet locally. I know that it dos not count if it worked on the local machine :smiley:

To connect the website with rasa we wrote the java Script file. For now the Website is hostet on the debian server and works fine, but there is no connection to the backend so far.

ok, got your point, but if your website is static it will later create a lot of issues, as I told I don’t know about AJAX, pinging @ChrisRahme for suggestions and help, many thanks in advance Chris.

@nik202 Thank you.

@timon.su hope he will help you on this and good luck!

You change it where you mentioned it in your code. Instead of localhost, use the IP.

Is that what you meant? Not sure I understand what’s the problem here, sorry.

I can share how to make Rasa chatbot with Botfront webchat frontend, if you are interested?

@InnoOmnia Yes, probably that would be helpful.

@ChrisRahme Thank you for your answer. We tried using the IP, unfortunantly it does not work.

We created a Rasa Bot und made a costum widget/website with HTML and CSS. After this we transfered the messages with a Java Script file and Ajax to the Frontend. Locally hosted everything worked finde. Now we want to deploy the bot on an debian server. Howerver unitl now we do not know how to set it up, so it is working on the Server. Do you have any advices?

Ah so the bot is not even deployed on the server? In any case, I want to make sure you deployed correctly:

Doing pip install rasa is only for local mode, not server mode. To deploy on a server, you can choose one of three methods:

Then, communicating with the Rasa server is pretty easy in itself - Just GET s and POST s to the Rasa Server at http://<IP>/webhooks/rest/webhook instead of http://localhost:5005/webhooks/rest/webhook (at least for the first two methods, not sure about Docker).

Or if you want to install Rasa open source then follow this guide

1 Like

@ChrisRahme is there a simple way to test the bot on an simple webspace with rasa open source?

Ok here it is, I run Apache2 server with subdomains, here is website
index.html

<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <script src="https://cdn.jsdelivr.net/npm/rasa-webchat@0.11.12/lib/index.min.js"></script>
    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>

<div id="webchat"></div>
<script>
  WebChat.default.init({
    showFullScreenButton: true,
    selector: "#webchat",
    initPayload: "/tervetuloa",
    customData: {"language": "fi"}, // arbitrary custom data. Stay minimal as this will be added to the socket
    socketUrl: "http://aspabotti1.omnia.fi:5005",
    socketPath: "/socket.io/",
    embedded: false,
    title: "AsPa botti",
    subtitle: "Asiakaspalvelun harjoitus botti",
    inputTextFieldHint: "Vastaa kysymyksiin",
    profileAvatar:"robot_icon.png",
    params: {"storage": "session"} // can be set to "local"  or "session". details in storage section.
  })
</script>

</body>
</html>

credentials.yml

socketio:
  user_message_evt: user_uttered
  bot_message_evt: bot_uttered
  session_persistence: true

and then you need to run rasa in port 5005

I use docker, so my actual commands are little bit different, but hope you get idea what to do?

1 Like