Is it possible to integrate API.Ai into a web channel? Microsoft Bot framework has an option that the bot can be invoked through a web chat along with FB messenger, skype etc. For this MSFT provies a chat url which can be embedded in any html page. Can the same happen through API.AI?
Is it also possible to invoke the NLP part of API.Ai, like the trained intents, context etc. from any stand-alone application?
Yes you can invoke the NLP part of api.ai with the help of events.
First create events with the help of the following URL :
https://docs.api.ai/docs/concept-events
Now from your web application you could use the following code to invoke these events,
HttpClient httpClient = HttpClientBuilder.create().build();
HttpPost request = new HttpPost("https://api.api.ai/v1/query?v=20150910");
StringEntity params =new StringEntity("{\"event\":{ \"name\": \"custom_event\", \"data\": {\"name\": \"Sam\"}}, \"timezone\":\"America/New_York\", \"lang\":\"en\", \"sessionId\":\"123abc\"}");
request.addHeader("content-type", "application/json");
request.addHeader("Authorization", "Bearer 0651225b57464d209936252796106e59");
request.setEntity(params);
HttpResponse response = httpClient.execute(request);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null)
{
System.out.println(line);
}
This would then return you the appropriate response.
Yes you can.
You need to build a frontend application ables to invoke api.ai services (by api.ai sdk).
Related
const newMessage = {
"name": "PushChangesToServicePortal_TEST",
"sys_name": "PushChangesToServicePortal_TEST",
"rest_endpoint": "XXXX-api",
};
let createMessageRes = await post(RESOURCE_URL, newMessage, {"Authorization": auth});
I'm able to create outbound REST Message using this code. How can I add/create HTTP method into it using table API?
You can generate javascript code for the request you want with "Rest API Explorer" in "System web services" in SNOW. How to article here:
https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/integrate/inbound_rest/task/t_GetStartedAccessExplorer.html
Documentation of the API is here:
https://developer.servicenow.com/app.do#!/rest_api_doc?v=newyork&id=r_TableAPI-GET
I'm trying to integrate a very small custom web application with NetSuite. I want a custom record to be created in NetSuite whenever a user clicks a button in my web application.
I have written a RESTlet that works with the REST API Testing chrome extension. I have successfully created records through that chrome extension.
However, when I try to POST from my web application, I get this error:
"Response to preflight request doesn't pass access control check: No
'Access-Control-Allow-Origin' header is present on the requested
resource. Origin 'null' is therefore not allowed access. The response
had HTTP status code 401."
How can I POST to NetSuite with a RESTlet from an external site? Should I even be using a RESTlet or is there a better way?
RESTlets are meant more as a system to system technology. They require authentication and if you are doing that from a public app your credentials will be compromised.
Netsuite doesn't allow you to set a CORS header so your cross domain integration needs to be via a publicly available suitelet and JSONP.
Since JSONP makes use of get requests you need to make sure your url params end up less than about 2k characters. That's not a standard limit so ymmv
patterns I often use:
Client code:
var url = "public suitelet url from deployment screen";
var params = {
mode: 'neworder',
//simple name/value data
};
$.ajax({
url: url+"&"+ $.param(params) +"&jsoncallback=?",
cache:false,
dataType:'json',
success: function(jResp){
if(!jResp.success){
if(jResp.message) alert(jResp.message);
return;
}
// act on the results
}
});
A library function in the suitelet source file.
function _sendJSResponse(request, response, respObject){
response.setContentType('JAVASCRIPT');
//response.setHeader('Access-Control-Allow-Origin', '*');
var callbackFcn = request.getParameter("jsoncallback") || request.getParameter('callback');
if(callbackFcn){
response.writeLine( callbackFcn + "(" + JSON.stringify(respObject) + ");");
}else response.writeLine( JSON.stringify(respObject) );
}
and then a Suitelet function
function service(request, response){
... do some work and generate a response
var returnObj = {
success:true,
message: '',
result:result
};
_sendJSResponse(request, response, returnObj);
}
That's your browser and its CORS setting
If using chrome ( you should be ;) ) on Windows, create a chrome shortcut with the following flags
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-web-security --user-data-dir
Then, kill/restart ALL INSTANCES of chrome in the Task Manager and try your requests again
Otherwise google "disable CORS on MY_BROWSER"
The example given on this website working properly following is the link https://blogs.msdn.microsoft.com/brunoterkaly/2012/02/28/node-js-a-chat-server-written-in-node-and-a-client-app-written-in-c/#comment-12985
but when i am trying to implement this client app in uwp template .
issues are coming in Tcpclient , NetworkStream and some other classes which are not available in uwp.
The chat client in the blog you posted here is a WPF project, not a uwp app project. Classes like TcpClient and NetworkStream under System.Net.Sockets namespace are not supported in uwp.
In uwp we use classes under Windows.Networking.Sockets namespace instead, E.g.StreamSocket, StreamSocketListener and so on. More details please refence the sockets official documents in uwp. And the uwp official sample about sockets is here.
I also helped you transferred the chat client in the blog from wpf to uwp, you can directly download it from GitHub for further testing.
Parts of the code for uwp chat client:
private async void cmdConnect_Click(object sender, RoutedEventArgs e)
{
AddPrompt();
Windows.Networking.HostName serverHost = new Windows.Networking.HostName("127.0.0.1");
await tcpClient.ConnectAsync(serverHost, "8000");
serverStream = tcpClient.OutputStream.AsStreamForWrite();
StreamWriter writer = new StreamWriter(serverStream);
string request = txtChatName.Text.Trim() + " is joining";
await writer.WriteLineAsync(request);
await writer.FlushAsync();
Stream streamIn = tcpClient.InputStream.AsStreamForRead();
StreamReader reader = new StreamReader(streamIn);
string response = await reader.ReadLineAsync();
}
I have an app on the appworld and I would like to add a link to it in my app so that people can more easily rate it. Normally on the android market I would do something like:
Uri uri = Uri.parse("market://details?id=com.example.test");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
Or on Amazon I would do:
Uri uri = Uri.parse("http://www.amazon.com/gp/mas/dl/android?p=com.example.test");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
But when I try the following it does not work:
Uri uri = Uri.parse("appworld://content=000000");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
It pops up a browser and then I get a message about not being able to do it or something. I also tried to launch to the appworld website page but appworld isn't grabbing it. What would be to correct way to handle this link?
The normal market:// link should actually work.
The normal market:// URI didn't work for me. The BlackBerry World app would always show the error:
There was a problem loading this Page due to a network error.
The fix was to detect when my app was running on a BlackBerry device then to use a different URI:
if (java.lang.System.getProperty("os.name").equals("qnx")){
marketUri = "appworld://content/1234567"
} else {
//normal Google Play URI
}
You can get your content ID from the BlackBerry World Vendor Portal by clicking on the 'edit' link next to your app. The ID is shown in the first field.
I have already requested and gained access to 'manage_pages' and 'publish_stream' permissions from a user. How can I use the c# SDK to get permission to post to one of that user's Business Pages wall (They must select one if they Admin multiple Pages, right?). Once I have that access, what is the best method to use the SDK to post to the Business Page wall?
On a related note, can the C# SDK run under ASP.NET 3.5 effectively? Rackspace Cloud Sites is not allowing .NET 4.0 on production servers yet, so I need to see code examples that don't use the 'dynamic' or 'ExpandoObject' keywords.
Thanks!
following is the code if it helps you
FacebookApp fbApp = new FacebookApp();
FacebookApp app = new FacebookApp(fbApp.Session.AccessToken);
var args = new Dictionary<string, object>();
args["message"] = "abc";
args["caption"] = "This is caption!";
args["description"] = "This is description!";
args["name"] = "This is name!";
args["picture"] = "[your image URL]";
args["link"] = "[your link URL]";
app.Api("/me/feed", args, HttpMethod.Post);
You need to replace /me in app.Api's arguments to the specific id of page.
I'm not sure if its the right way, but it works for wall post of a user :-)
Here's how with c# SDK 5.1.1
FacebookClient fbClient = new FacebookClient(accessToken);
var args = new Dictionary<string, object>();
args["message"] = "Testing 123";
fbClient.Post("/me/feed", args);
args["picture"] = "[your image URL]";
args["link"] = "[your link URL]";
The image url and link won't work if you give a localhost address.You can try by giving url of an image in a remote server.