You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can anybody share a code snipped of how to make an ajax POST request in
Javascript object macro in a RiveScript...
Kirsle has talked about it here.
But this example doesn't work.
Or maybe there's some other way of making this work.
This is what I am trying to do:
This is the bot Response: "hello.[ERR: Object Not Found]"
The text was updated successfully, but these errors were encountered:
Check your browser console for any errors. The "Object Not Found" probably meant your object macro failed to parse correctly in the first place (syntax error for example).
rs.getUservar() nowadays returns a Promise and not a string, so you'll need to await it or .then() it to use its value. In RiveScript.js 2.0.0, the inline object macros defined using > object are parsed in as async functions by default so you may use the await keyword in them, provided your calling code is also coming from an async function.
(example if unfamiliar with async/await)
// if you had a global bot in an `rs` variable like on a web pagevarrs=newRiveScript();// your function to get a reply needs to be an async function (well, your whole// call stack has to be but usually you'll have one entry function of your own)// rs.reply() is an `async function` and RiveScript takes care of the rest, but// if your call stack isn't all async you can't use `await` -- check your console for// that errorasyncfunctionsendMessage(username,message){// you can use the await keyword to wait synchronously on any Promisevarreply=awaitrs.reply(username,message);returnreply;}
In that sort of setup the async function in the object macro is allowed to use the await keyword.
Can anybody share a code snipped of how to make an ajax POST request in
Javascript object macro in a RiveScript...
Kirsle has talked about it here.
But this example doesn't work.
Or maybe there's some other way of making this work.
This is what I am trying to do:
This is the bot Response: "hello.[ERR: Object Not Found]"
The text was updated successfully, but these errors were encountered: