Using Microsoft's serverless Logic App, LUIS AI, and .NET Core API, generate a travel quote to a user through a variety of channels.


I've been using the Solartis API suite for several years as a developer and now director at Starr Companies. I have already developed and led development on UI's that basically serve as wrappers around the Solartis platform, so for this hackathon I wanted to explore a different avenue than a standard website.

A challenge we have had with our internal DTC applications is justifying the marketing spend of getting our products advertised versus the amount of premium that we will be able to write as a result of the advertisements. This was the initial inspiration to creating this project.

I've seen different twitter accounts that anyone in the world can tweet to in order to get a response. I thought that using the Solartis Travel API, I could create a "Travel Insurance Bot" that would give users a quick quote, that would allow insurance companies to market globally with very little money.

Of course, I did not want to write a ton of code that would only work for specific channels, and I did not want to have to use classic keyword parsing to gather the user's information. I wanted to have an extendable solution with minimal dependencies on the actual code base -- if I wanted to abandon twitter and support Cortana commands or Facebook messenger, I did not want to rewrite much code.

What it does

The app monitors a specific hashtag (#adamhack19). For tweets that come in to that hashtag, each tweet is fed to the LUIS AI platform to extract the origin and destination of the tweet using NLP. The LUIS application then responds to the app with the detected entities, the app then calls the Solartis Leisure Travel API, and responds to the user with a rate. A .NET Core Web API is called during the process for better data extraction.

As mentioned, I started with the twitter channel as a demo, but as mentioned this can work on several different channels with minimal changes.

How I built it

Tech used: Azure Logic App, LUIS AI application, .Net Core 2.1 Web Api, Azure Web App, Twitter API account

Since I wanted this application to not be tied to a specific code base, I created an Azure Logic App which uses Azure's serverless tech and allows rich tooling through their Designer UI. By using this method, I could also clone and extend this solution to several other channels simply by modifying the incoming trigger of the Logic App. Important to note the Logic App can handle large batches concurrently.

The Logic App starts by monitoring twitter. For the twitter channel, I created a twitter account and requested an API key to interact programmatically with the twitter application. I integrated this twitter handle to my Logic App so that I could read and respond to tweets through this account. Since I would not want to have to process logic for every tweet, I put in filters to only respond to tweets going to #adamhack19.

Once a tweet is detected, the Logic App kicks off its first step by feeding the incoming tweet to my LUIS application. For my LUIS application, I wanted to use natural language processing to detect origin and destination instead of a hardcoded list. This way I can train my model to recognize even if ordering is off, or language is changed in the future. Using LUIS, it is very easy to test and train the model to get predictable results. The purpose then of my LUIS application is to return Entities matching my origin and destination.

Since the LUIS connector does not have the ability to gracefully extract the Entites, I call my own .NET Core Web API that simply extracts the Origin and the Destination, and stores it in a local variable I can reference later in my Logic App workflow. The API also does things like extract state code from the input origin, and country name from the input destination.

The next step is to call the Solartis Travel API. I was able to use the Solartis Swagger documentation to integrate Solartis' API with Logic Apps using a custom Logic Apps Connector. This simple integration would allow external users, such as Insurance companies, to integrate with Solartis APIs in a graphical and straight forward way. The extracted Origin and Destination are passed into the Solartis API call.

The custom connector I made calls the Solartis travel API and returns a response object which I am then sending to my own .NET Core 2.1 API to parse out the results. I hosted this in Azure Web App platform as a service. Once the Solartis swagger spec has an updated return property for the return objects, I would be able to bypass this step altogether.

Back in the Azure Logic App, I now have a rate that I can tweet back at the user.

Challenges I ran into

On the twitter side, I was originally wanting to monitor all tweets of users traveling and respond with a quote, but that is against their Terms of Service -- additionally, some tweets that I originally targeted as traveling with sufficient information were not ones a company would actually want to target. For example, one early on that was recognized by my app was a fellow traveling to his grandparents funeral -- imagine if an insurance company replied by saying "You can insure this trip for $50!". The user would not be happy about that. At the end of the day, I think only responding to users is a much better experience as the insurance quotes will not be considered as spam or unwanted solicitation by the insurance company.

I also found out via the Microsoft connector to twitter, mentioning a @user while posting a tweet is not supported. Specifically, the "@" characters will be stripped while posting a tweet. So my responses cannot target the user directly.

The Logic App itself can be a little limiting due to the built in connectors offered, and the enforcement of Microsoft's Logic App workflow langauge syntax. I was able to get around most of it, but the native LUIS connector does not offer ability to access entities without creating iterative loops around the logic, which is why I had to stand up a method in my .NET Core Web API to extract the entities manually.

Regarding the custom Logic App Connector, there are some limitations due to the current Solartis swagger spec that could be easily fixed by the Solartis dev team to make the integration even more powerful. This is I believe due to the return object not being clearly defined in the spec.If this was adjusted, any Logic Apps user could have full granularity of every single request and response attribute directly from the Logic App UI!

Accomplishments that I'm proud of

By importing the Solartis API spec into the Logic App Custom Connector, there is potentially huge customization and reuse there that Solartis can provide to their clients -- Imagine entire application workflows demo'd straight from the Logic App interface -- showing clients that they can kick off workflows from a single webhook trigger, potentially cross reference client information from Salesforce or even their own back end systems, and then call out to Solartis for a Rate / Quote / Bind process. It is a very slick workflow builder that I've seen in several other platforms but not as nicely executed as the Azure interface.

As mentioned above, the Solartis spec can be expanded on to give access of all request and response parameters from directly in the Logic App UI. This could be extended to considering custom trigger points on other Azure serverless tech, like custom trigger points on Azure Functions.

I also feel pretty good about the model I trained for the LUIS application, and that I was able to get a good amount of the work done via Logic App instead of coding it all in my own API. After minimal training utterances, the LUIS application was able to pick up my origin and destinations pretty easily. If I spent more time fine tuning, I believe it could be extremely accurate in this regard. Another benefit is it supports multi-languages, so would be much easier to extract from another language than to code lists manually.

What I learned

Using twitter for this sort of thing may not be a realistic use case for effective marketing, but it could get people excited about the insurance carrier or the Solartis back end powering the rates. I ended up being much more excited about the overall process and pieces involved than the potential marketability of the solution.

I had never trained a model for natural language processing using LUIS before -- I had been exposed to LUIS but mostly stuck to using Lists and synonyms. Using nlp is very cool, but for things like city or country recognition, in retrospect it could be just as effective (but would take more initial code) to use predefined lists. However, it could be cumbersome to duplicate and switch based on client language, if that was not always English, where the LUIS app would excel in its re usability.

I also never created a Logic App Connector before, but thanks to Solartis's swagger site, I was able to download the json and get 99% of what I wanted. You can actually customize Logic App connectors to provide even more actions and scale for async processing, pub/sub processing, and some other really neat workflows that Microsoft offers.

The largest takeaway for me here is the Logic App connector, and how Solartis or any other company that has proper Open API documentation can create their own connectors for this and other serverless Microsoft tech.

What's next for Solartis Auto Quote

The ability for a user to talk more colloquially to the bot -- to really show off the power of the nlp better. I had the nlp to extract origin and destination pretty well, but with more training on the LUIS application, it could become much more intelligent.

I would like to actually expose this to another channel other than twitter -- the great part about that it is very easy to clone Logic Apps and the LUIS model would be 100% reused. I could also further enhance the Logic App flow so that if a piece such as origin or destination was not recognized, it could prompt the user and execute a separate workflow. For this type of contextual communication workflow, I would probably switch to Azure Bot-Apps instead of Logic Apps.

I would also train up the LUIS model up or try out and compare versus a List based model to make sure I have 100% accuracy on all cities / countries in the world. The List should be able to get exact recognition on the cities, but I think the NLP model would actually have a benefit on how it can detected the destination vs. origin due to contextual clues.

I would also customize the Solaris spec slightly so that the Logic App could have full access over all of the Response elements from the Travel API -- that way I would not need to call any intermediate API and could respond directly from the Logic App. I could do the same for LUIS -- this way I could avoid my extraction APIs as well.

Based on the channels targeted, I would also try to collect more information from the end user so I didn't have to default most attributes, or look into a more contextual question/answer workflow.

Please feel free to reach out with any questions, I created a poorly made full walkthrough as well, at https://www.youtube.com/watch?v=wN3QhIpTTo8.

Thanks for this opportunity and your consideration.

Built With

Share this project: