Intro to Calling Third Party AI Services in Unreal Engine

For the past couple of nights, while plowing through the codebase, I've been working on a plugin that allows…forums.


com[Plugin] Http/s REST, blueprintable JSON and Parse REST API manager at once (VaRest)Discuss GitHub, using source code to modify the engine, and the creation of engine plugins.



comI found two promising plugins, VaRestPlugin and JSONQuery.

Both showed promising screenshots, but I went to VaRestPlugin and decided to give it a spin.

But how do I Blueprint?Working with BlueprintsThis next bit is going to be more of an applied learning of Blueprints, so if you are looking for definitions might I recommend the documentation which, of course, I didn’t read because why would I take the time to do that when I want to do a something.

Blueprints is listed on that main project view and provides a drop down.

I chose “Open Level Blueprint” hoping that would get me in a place that would automatically trigger at the start of the game (or at least give me function options like I saw in the C++ component rather than creating a new Blueprint component and worrying it would never get called.

I stumble my way through the Blueprint UI trying to add new nodes.

Right clicking on the UI does what I would expect it to, allow me to add new nodes.

But between context sensitive and non-context sensitive nodes… I have SO MANY OPTIONS.

Building the FlowFeeling overwhelmed I manage to get myself into the VaRestPlugin section.

All I want to do so pull in nodes similar to a screenshot I saw to build a GET.

Which should look something like this:Fire BeingPlay(?) event > Build GET request (plus auth) > Fire GET request > Print JSON resultVaRestPlugin gives me everything I need, but I realize I’ll need to authenticate with basic authentication, with only a key/value pair situation in the header.

Non-issue really, I go pull my hashed auth header out of Postman, that I used for testing this particular GET to make sure the service isn’t throwing any weird errors as I’m building it out here.

I add “Authorization” to Header Name, and put my hashed auth header in “Value”.

Before I get set a header, I need to construct the request object, specifying the verb.

I find the “Construct JSON Request” node.

I need a place to actually put the URL, so I start investigating “Apply URL” and “Process URL”.

“Apply URL” seems to actually return something, where “Process URL” just initiates the request.

This one is pretty explanatory, the URL you want to hit goes in the URL field.

But how do I print the request object result?Hmm.

Frustrating with Blueprints…I get everything together except except the absolute easiest, most basic node “SET”, which I can only assume is what I need to build the overall request.

I give up for 2 days.

I see no “SET” in the VaRestPlugin node section and I’m annoyed with myself.

I decide to read the Blueprint documentation, particularly the Variables section.

I realize very quickly that I’m looking to create (and set) an object (variable).

I also realize my event trigger is wrong too.

The “My Request” object becomes the target for all the request building nodes.

But I’m still not sure about printing the response, but I end up finding some information about encoding the JSON and printing the string.

Succeeding with Blueprints!Finally I build a GET for returning customized acoustic audio files I used to train my custom acoustic model for Watson Speech to Text.

I cross my fingers, save/compile and then hit the play button.

It works!!!.I see a list of my audio files in the console!Now what?I can’t really do a lot with this, but it does get me through the hurdle of just connecting to a REST service and getting back a response.

Now I can work on building a similar example to my AR pattern in Unity.

Interested in seeing that?.Because I’m interested in building it if you are!Are you building something in Unreal Engine that could leverage AI services?.Let me know in the comments!.

. More details

Leave a Reply