Gupshup Chat Web Widget Redirection Issue
I have built a bot with Gupshup which is really a cool tool. They provide us a web widget can be put on to any website. But there seems to be really serious problem with the widget
Solution 1:
You can create a custom html page hosted on any domain and load bot widget within iframe tag. This is the html code with iframe.
<html>
<head>
</head>
<body>
<iframe id ="some_iframe_id" style="position: absolute; top: 0px; left: 0px; width: 99%; height: 99%; margin: 0px; padding: 0px;"></iframe>
<script>
window.tcAsyncInit = function (a) {
var userid = "anon:" + Math.floor(Math.random() * 100000);
var username="User";
a.init({
botkey: "{{BOT_KEY}}",
version: "3",
appUISetting:"%7B%22openMode%22%3A%7B%22text%22%3A%22Mubble%20Assistant%22%2C%22height%22%3A390%2C%22width%22%3A320%7D%2C%22closeMode%22%3A%7B%22text%22%3A%22Mubble%20Assistant%22%2C%22width%22%3A250%2C%22displayType%22%3A%22rectangular%22%7D%2C%22common%22%3A%7B%22logo%22%3A%22https%3A//www.gupshup.io/images/botwidget/ic_dummy_chat_g.png%22%2C%22imgDispType%22%3A%22circular%22%2C%22bgColor%22%3A%22%23765999%22%2C%22fontSize%22%3A16%2C%22fontColor%22%3A%22%23ffffff%22%7D%2C%22content%22%3A%7B%22bot%22%3A%22https%3A//www.gupshup.io/images/botwidget/ic_bot.png%22%2C%22botBubbleColor%22%3A%22%23f5f5f5%22%2C%22botFontColor%22%3A%22%23797979%22%2C%22user%22%3A%22https%3A//www.gupshup.io/images/botwidget/ic_user.png%22%2C%22userBubbleColor%22%3A%22%23765999%22%2C%22userFontColor%22%3A%22%23ffffff%22%2C%22pageTitle%22%3A%22Chat%20Bot%22%2C%22fontSize%22%3A14%2C%22fontFamily%22%3A%22sans-serif%22%7D%2C%22config%22%3A%7B%22persistenceMenu%22%3A%22%7B%5C%22disableinput%5C%22%3Afalse%2C%5C%22menu%5C%22%3A%5B%7B%5C%22title%5C%22%3A%5C%22Level1%20-%20Element1%5C%22%2C%5C%22type%5C%22%3A%5C%22nested%5C%22%2C%5C%22menu%5C%22%3A%5B%7B%5C%22title%5C%22%3A%5C%22Level2%20-%20Element1%5C%22%2C%5C%22type%5C%22%3A%5C%22text%5C%22%7D%2C%7B%5C%22title%5C%22%3A%5C%22Level2%20-%20Element2%5C%22%2C%5C%22type%5C%22%3A%5C%22nested%5C%22%2C%5C%22menu%5C%22%3A%5B%7B%5C%22title%5C%22%3A%5C%22Level3%20-%20Element1%5C%22%2C%5C%22type%5C%22%3A%5C%22text%5C%22%7D%5D%7D%2C%7B%5C%22title%5C%22%3A%5C%22Level2%20-%20Element4%5C%22%2C%5C%22type%5C%22%3A%5C%22nested%5C%22%2C%5C%22menu%5C%22%3A%5B%7B%5C%22title%5C%22%3A%5C%22Level3%20-%20Element1%5C%22%2C%5C%22type%5C%22%3A%5C%22text%5C%22%7D%5D%7D%2C%7B%5C%22title%5C%22%3A%5C%22Level2%20-%20Element5%5C%22%2C%5C%22type%5C%22%3A%5C%22text%5C%22%7D%5D%7D%2C%7B%5C%22title%5C%22%3A%5C%22Level2%20-%20Element4.1%5C%22%2C%5C%22type%5C%22%3A%5C%22text%5C%22%7D%5D%7D%22%2C%22perMenuImg%22%3A%22%22%2C%22attachment%22%3A%22Yes%22%2C%22widgetType%22%3A%22Text%22%2C%22msgEnc%22%3A%22No%22%2C%22webView%22%3A%22Yes%22%2C%22RDStatus%22%3A%22No%22%2C%22isResponsive%22%3A%22No%22%7D%7D",
userObj: {
"roomid": userid,
"sender": {
"id": userid,
"name": username
},
"recipient": {
"id": userid,
"name": "Bot"
},
"message": {
"text": "Hello",
"type": "text"
}
}
}, function(){
document.getElementById('some_iframe_id').src = a.getRedirectUrl();
});
};
</script>
<script id="gs-sdk" src='//www.buildquickbots.com/botwidget/v3/demo/static/js/sdk.js?v=3' key="{{BOT_KEY}}" callback="tcAsyncInit" ></script>
</body>
</html>
You can get your appUISetting string with below URL : https://botwidget.gupshup.io/ChatChannel/api/bot/{{botKey}}/botconfig
Solution 2:
Gupshup's Web widget is hosted on Builquickbots.com hence when you open it using the mobile devices it redirects to the URL. This is how the current behavior of the Web widget is.
You can configure CNAME record in your DNS and point it to buildquickbots.com. This will redirect the request to your domain but will only work on HTTP.
It is technically not possible to do it for HTTPS because of SSL certificate limitations.
Post a Comment for "Gupshup Chat Web Widget Redirection Issue"