Comments (10)
Hi Andrew,
We've been thinking about CORS for a while. Our concern is that your authorization access token would be visible to your website visitors. That's why we thought a proxy would be better (of course it comes with so drawbacks, like latency and having to set it up).
Since the same access token enables you to access the REST API for potential write operations on your instance, it's really not possible to make it public in your HTML code. Later, we may use several access tokens with different scopes, one of them being restricted to GET/message, that you could use for CORS.
If somebody has a better idea, please let us know.
from wit.
I was worried about that too, but for prototyping purposes, it wouldn't be a concern (which is where I'm at right now). Have you considered JSONP at all?
from wit.
We do support JSONP, as an experimental feature.
However, you can't use headers with JSONP, so you'll need to pass the access token as a 'access_token' query parameter.
Also, you want to use a GET request here.
from wit.
Can you provide a JSONP sample? I tried providing an access_token get parameter but I get a HTTP/1.1 403 Forbidden
from wit.
Hi Guillaume,
Here is a jsonp example using jquery
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Demo</title>
</head>
<body>
<script src="jquery.js"></script>
<script>
handleResult = function(textResult) {
$.ajax({
url: 'https://api.wit.ai/message',
data: {
'q': textResult,
'access_token' : "YOUR_TOKEN"
},
dataType: "jsonp",
jsonp: "callback",
method: 'POST',
success: function( response ) {
console.log( response ); // server response
}
})}
handleResult("Book meeting with Henri tomorrow at 5pm");
</script>
</body>
</html>
Let me know if it works for you.
from wit.
Thanks. I tried but neither jQuery 2.x nor AngularJS allowed me to POST JSONP requests, I'm not sure where the probleme come from, perhaps Chrome specific, I'll take a look later.
Edit: ok actually it can't work since JSONP just use a script tag wich will make a GET
from wit.
any update? how can we use "POST" method in Ajax, jQuery. We tried JSONP before and it gave bad URL exception.
from wit.
JSONP can only be used with GET. If you really want CORS, please reopen an issue and we'll leave it open as a feature request to see if it gains traction
from wit.
ok. thank you. i will ask another: is there any other way of getting bot's response to my query in my web site?
from wit.
You can use the GET /message
API from your website, as this does not require CORS.
You'll need to write some code to generate a bot answer from the intent and entities you extract.
CORS support has been requested here #242 by the way
from wit.
Related Issues (20)
- Timestamps not aligning with audio HOT 1
- Character Encoding Critical Bug - Foreign language apps do not tag existing explicit keywords HOT 4
- when importing intents from app to another, not all expressions are added
- Is there any plan to add audio/mp3 to POST Synthesize HOT 2
- App training issue HOT 4
- my app unable to train HOT 1
- Intent mismatch wrt character case(Upper/Lower) HOT 3
- Utterances are not all imported HOT 1
- HTTP API error "Something went wrong. We've been notified" with code "unknown" (Status code 500 - Internal server error)
- Wit does not match pretty obvious intents HOT 1
- Contributors added via API. HOT 1
- Urgent Bug - service returning "Bad auth" sometimes HOT 2
- Wit adds plus signs to promt HOT 1
- Wit.ai Composer is unable to deploy flow to the runtime
- bot not responding appropriately to utterances HOT 2
- Irrelevant response to wit api HOT 3
- Wit.AI 500 Internal server Error HOT 2
- Troubles while using context parameter in message endpoint HOT 2
- please.something went wrong
- Weird encoding case with Greek language HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wit.