Use Content Aviator directly from another application like Microsoft Word

Phil Cox
Phil Cox E Community Moderator
edited November 18 in Articles #1

We have all seen how we can use natural language questions using Content Aviator against a Business Workspace or a document. OK It's great functionality. However in our example where we receive questions via a Word document copying the question into Content Aviator then getting the reply to having to copy back into the reply box. If you are like me you might have already forgotten what row you need to paste the answer into!

With a simple Word Add-In we can send the highlighted text straight to Content Aviator and then just simply paste the response into the box for our answer. Very efficient. No mistakes and easy for any user to be able to do.

And below is our reply. We just needed to Control-V to paste the reply which was already in the Clipboard.

How nice is that..?

It is very easy to do. Like most of these projects we start with PostMan to test and authentication and URL endpoints. However before that you will need to ensure that your Core Content instance has a Service Client as we need this to be able to Authenticate

In our example our Service Client ID starts with "cd759….." So now into postman to see how we build our Authentication. The below has had the password and secret blanked out

Once we send this we get on receipt our token with will we use for further communications.

Now we have our "access_token" we can continue to investigate how we will consume Content Aviator.

Now we have our working POST URL in PostMan we can start to implement this in our VSTO PlugIn for Word.

In Visual Studio we need to create a new project based on VSTO PlugIn

Then in the Ribbon1.vb depending on the users selection, we will set the workspaceID of documentID as well as the document or workspace identifier.

Public Sub AviatorCompWorkSpace(control As IRibbonControl)

Dim SrcVal As String = ""
Dim SrcID As String = ""
Dim SelText As String = Globals.ThisAddIn.Application.ActiveDocument.Application.Selection.Text

SrcID = "workspaceID"
SrcVal = "bc3afdd5-848a-41fb-ae2d-0a7e9371cb22"

Dim newSelText As String = SelText.Replace(vbCr, "").Replace(vbLf, "")
Globals.ThisAddIn.AviatorQuery(newSelText, SrcID, SrcVal)
End Sub

Once these have been set, we can look at passing the highlighted text as part of the sending POST in JSON format to the URL we see in PostMan above. Depending on which menu item the user selects will determine what values we set for documentID or workspaceID as well as highlighted text.

The last surprise Visual Studio had for me was that before I could pt the reply into the clipboard I had to switch into STA Single Threaded mode.

Once that was done it's simple for the user to simply Control-V the answer into the desired field.

I hope this gives you ideas on how to increase user productivity by using Content Aviator in your applications.

Many thanks