IBM's Watson Assistant has stopped responding - ibm-cloud

Just over a year ago I created a chatbot using IBM Watson Assistant. It is successfully interfacing with wordpress and facebook. it was working perfectly well in a web page too, but has now stopped outputting any text. I created the website integration by copying the code shown in the "preview link" page created by IBM when the bot is under development. That code includes a library file called "chat.0.0.4.js" and corresponding css. When the code runs now, the chatbot renders correctly, but when I look at the browser console I see at line 12990 in chat.0.0.4.js:
400 - {"error":"Invalid Request Body","errors":[{"message":"When source.type is not 'watson', source.id is required
Does anyone know how to fix this? I see that the integration code from the "preview link" is now totally different and I wonder if the mechanism I used a year ago is now depreciated?
Thanks.

I think you need to use the newer version, the script to integrate WA has changed and now looks like this:
<script>
window.watsonAssistantChatOptions = {
integrationID: 'YOUR_INTEGRATION_ID',
region: 'YOUR_REGION',
serviceInstanceID: 'YOUR_SERVICE_INSTANCE',
onLoad: function(instance) {
instance.updateUserID(L12345);
instance.render();
}
};
setTimeout(function(){
const t=document.createElement('script');
t.src="https://web-chat.global.assistant.watson.appdomain.cloud/loadWatsonAssistantChat.js";
document.head.appendChild(t);
});
</script>

Related

Why does Facebook leadgen ads testing tool give a 102 server error?

I've created a Facebook app, linked it with a business, submitted and passed review, the business is verified, contracts signed, the app has leads_retrieval permission, the app status is now live.
I can test it under the webhooks link in the side menu, my end point receives the test data from Facebook. The data shown below is received by my server.
When I test using the lead ads testing tool I instantly get a 102, server error, and nothing is received by my server. See below for the message.
I've spent so long getting to this stage and every step has been painful!
Can anyone suggest why using the lead ads testing tool results in an error and what I can do to resolve the issue.
Cheers
I've been struggling with this too.. Apparently you can't use it on development apps anymore. Found the answer here: https://stackoverflow.com/a/57397525/8439792
I think I found your problem! It is when you subscribe to your apps. Here is the link that shows the subscribed_fields and scope should be:
https://stackoverflow.com/a/54713182/7313872
I was going straight from the demo and the subscribed_fields is set to 'feeds' and the scope was only manage_pages. You need to change it like in the example in the above link. I will also provide the snippets I changed below:
subscribed_fields - in subscribe apps function
FB.api(
'/' + page_id + '/subscribed_apps',
'post',
{access_token: page_access_token, subscribed_fields: 'leadgen'},
function(response) {
console.log('Successfully subscribed page', response);
}
);
scope - end of facebook login function
{scope: ['manage_pages', 'leads_retrieval']});
Hope this helps!
Facebook had the problem in their startup documentation for the webhooks. I have notified them in a bug, and does look like they have fixed the documentation to now subscribe to "leadgen" and not "feeds".
https://developers.facebook.com/support/bugs/681262475926363/
https://developers.facebook.com/docs/marketing-api/guides/lead-ads/quickstart/webhooks-integration/

Facebook login using Xamarin.iOS and Azure - 'Resource not found'

I'm following the example Xamarin.iOS Azure Facebook, and the implementation works fine on Android. It's not using facebook sdk, but opening the default webview. This is provided by the Azure.Mobile.Client SDK.
So... when running the 'same' application on iOS, an error appears before reaching the login view
'The resource you are looking for has been removed, had its name changed, or is temporarily unavailable'
The online platform specific code in the iOS project is exactly what comes from the documentation (link above):
user = await TodoItemManager.DefaultManager.CurrentClient.LoginAsync (
UIApplication.SharedApplication.KeyWindow.RootViewController,
MobileServiceAuthenticationProvider.Google);
In my solution this line looks like this:
var user = await _client.MobileServiceClient.LoginAsync(UIApplication.SharedApplication.KeyWindow.RootViewController, MobileServiceAuthenticationProvider.Google);
I'm running on iOS 10.2, using VisualStudio 2017 Pro.
You can see the whole solution on github
Never mind... I'm sorry, but looks like it was just too late for programming last night. The error was so obvious:
Instead of 'Facebook', I tried to authenticate against 'Google', because of copy&paste and being inattentive...
var user = await _client.MobileServiceClient.LoginAsync(UIApplication.SharedApplication.KeyWindowRootViewController,MobileServiceAuthenticationProvider.Facebook);

Codenameone browser issues with paypal checkout express

So I've been trying to find an API to integrate PayPal Payment into my Codename One App, except that I didn't find enough documentation to use the Purchase builtin feature. So I tried to use a WebView of a page hosted on my server and implemented using the paypal "checkout.js" Api.
When I load the page into Chrome, it works perfectly and the transaction is complete. But when I load it using the codename one BrowserComponent it gets stuck (See screenshot). What is the root of this problem ? Is it the fact that the browser does not support popus ? and Is there a way to fix it ?
Button payButton = new Button("Checkout");
payButton.addActionListener((ActionEvent evt) -> {
Form payForm = new Form("Payment", new BorderLayout());
WebBrowser webBrowser = new WebBrowser("http://localhost/paymentserver/web/app_dev.php/payerParticipation/5");
payForm.add(BorderLayout.CENTER, webBrowser);
payForm.show();
});
Screenshot
Try embedding firebug into the of your page to see if it reports any errors:
<script>
if (!document.getElementById('FirebugLite')){E = document['createElement' + 'NS'] && document.documentElement.namespaceURI;E = E ? document'createElement' + 'NS' : document'createElement';E'setAttribute';E'setAttribute';E'setAttribute';(document'getElementsByTagName'[0] || document'getElementsByTagName'[0]).appendChild(E);E = new Image;E'setAttribute';}
</script>
Thanks for the help everybody,
I finally found a turnaround and implemented this feature on a PHP server using PayPal PHP SDK. I used the browser Navigation Callback in order to check when the payment was successful/failed.
browser.setNavigationCallback((url)->{
if (url.indexOf("success=true")!=-1){
System.out.println("Payment complete");
}
else if (url.indexOf("success=false")!=-1){
System.out.println("Payment failed");
}
return true;
});
I don't have an answer for that but I did implement Braintree support for Codename One which is the official PayPal mobile API. I have a cn1lib for it implemented but I didn't get around to publishing it because of the bootcamp. Keep an eye on the blog I'll probably publish it in the next couple of weeks.

Unity3d web app facebook Sdk payments API Error Code: 1383008

I am developing a facebook game in Unity3d using facebook's new facebook sdk, running the app as a web app inside facebook in sandbox mode.
Today I started implementing a shop in the game for microtransactions using their canvas pay model. I read their documentation and javascript tutorial for payments (they don't have one yet for unity) and created a simple button that when you click you are able to buy some ingame currency(coins).
Now my open graph og:product is tested and looks accurate and my c# code in unity is this:
public void onCoinsClicked()
{
FB.Canvas.Pay(
product: "my_url/products/coin.html",
action: "purchaseitem",
quantity: 1,
testCurrency:"EUR",
callback: delegate(FBResult response) {
FbDebug.Log("The result of the purchase is: " + response.Text);
});
FbDebug.Log("onCoinsClicked: ");
}
When i test it using a payments tester user that i have, it throws the following error when displaying the payment popup:
An error occurred. Please try again later.
API Error Code: 1383008
API Error Description: The app you're using isn't responding. Please try again. If you keep seeing this error, try again in a few hours.
If some of you kind people have experienced this before please enlighten me :)
Thank you.
Have you run your product's URL through the Open Graph Debugger (https://developers.facebook.com/tools/debug)? It's possible that a crawler error is causing the issue, and it would be good to make sure that the problem isn't at the data level.

Azure mobile facebook authentication with iPhone HTML5 in app (full screen) mode

I have an HTML5 application that uses Azure mobile services authentication to login (straight from the example code...provided below). It works fine in all desktop browsers and iPhone 5 in Safari. But from app / full screen mode, it does nothing (doesn't ask for permission to show a popup window like it does in safari and no popup windows shows up) and I can wait forever and nothing happens. If I invoke it a second time, it gives an error saying "Error: Unexpected failure"...perhaps because the 1st attempt is still running? Any help/insight is appreciated.
client.login ("facebook").done(function (results) {
alert("You are now logged in as: " + results.userId);
}, function (err) {
alert("Error: " + err);
});
edited update with more info and 2 potential ideas*
I did some more research and found a site that uses an approach that overcomes this problem and also solves two other side effects with the current Azure mobile approach to authentication. I think the Azure mobile team might be looking to do something similar because there are some hints of other authentication options in the code (although difficult to read and be sure because the minimized code is obsfucated). It might be just a matter of activating these in the code...
The "solution":
Go to http://m.bcwars.com/ and click on the Facebook login. You'll see it works perfectly in iPhone Safari in "app mode" becuase instead of doing a popup, it simply stays in the current browser window.
This approach solves two other problems with the current Azure mobile approach. First, the popup gets interpreted by most browsers as a potential ad and is either blocked automatically (desktop Chrome) ... and the user doesn't know why it's not working...or gives a warning which the user has to approve (iPhone Safari in "browser mode") which is a hassle. And if the user has a popup blocker, it gets more difficult and even more potential for the user not getting it to work properly. The bcwars.com method doesn't have this problem.
Second, in iPhone Safari, when the popup window auto closes, the original page doesn't get focus if there are other browser windows open in Safari. Instead, it's in the smaller/slide mode so they can choose which one to show. If this happens, the user has to go through one more sttep...click on the browser window to activate it and give it focus..again more of a pain and more potential for them to mess up and not do it correctly and need help. The m.bcwars.com doesn't have this problem.
Azure options:
Looking at the Azure mobile code it looks like may already have the solution. I can't read it easliy becuase it's minified/obsfucated, but it seems to have 4 options (including iFrame, etc.) for invoking the authentication, and only 1 (the "less ideal one" of a popup) is being used. An easy solution would be to set a property to allow one of the alternate authentications to work. But I can't read it well enough to figure it out. Another would be to hack the code (temporarily until a fix is put up by Microsoft).
Could I get some help there perhaps?
You can implement an authentication flow with Facebook that doesn't use a popup. The basic idea is to use the 'Web Flow' for doing the login, and once the window return from the login, use the access token to login the user in to Azure Mobile Services.
The Facebook documentation for doing this is here:
https://developers.facebook.com/docs/facebook-login/login-flow-for-web-no-jssdk/#step2
Some code samples to make it easier for you.
You would start by something like this:
(Remember to replace YOUR_APP_ID and YOUR_URL with something relevant to your site.
function logIn() {
window.location.replace('https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=http%3A%2F%2FYOUR_URL&response_type=token')
}
This redirects the window to the Facebook page for the user to log in and authorize your app. When the user is done, Facebook will redirect the user back to YOUR_URL given above.
There you can handle the redirect and do the Mobile Services Login with something like this:
function handleLoginResponse() {
var frag = $.deparam.fragment();
if (frag.hasOwnProperty("access_token")) {
client.login("facebook", { access_token: frag.access_token }).then(function () {
// you're logged in
}, function (error) {
alert(error);
});
}
}
In here you parse the access token you get as a URL fragment and pass it as argument to the login call you make to Azure Mobile Services.
This code depends on the jquery BBQ plugin to handle the URL fragment easily.
Hope this solves your problem!