Logic Apps: Creating Issue On GitHub Repositories Using Gmail and LUIS
Introduction
While working on a repository which is shared across multiple developers sometimes it becomes necessary that an issue needs to be created for the owner of the repository to track and to assign it to a concerned party. This task is manual and the owner/administrator needs to go to GITHub to check and assign the issue and similarly, the developers also need to create the issue in the GIT. If this process can be automated intelligently so as to create and assign the issues without human intervention, then it becomes beneficial to both the parties. This article aims to discuss the automation of issue creation using Logic Apps and LUIS. The developers can send the mail to a target mailbox to create the issue and the Logic App workflow with the help of LUIS will intelligently understand the request and create the workflow.
Basic Concepts
What are Logic Apps?
Logic Apps are a piece of integration workflow hosted on Azure which is used to create scale-able integrations between various systems. These are very easy to design and provide connectivity between various disparate systems using many out of the box connectors as well as with the facility to design custom connectors for specific purposes. This makes integration easier than ever as the design aspect of the earlier complex integrations is made easy with minimum steps required to get a workflow in place and get it running.
What is LUIS?
As per Microsoft
"Language Understanding (LUIS) allows your application to understand what a person wants in their own words. LUIS uses machine learning to allow developers to build applications that can receive user input in natural language and extract meaning from it. A client application that converses with the user can pass user input to a LUIS app and receive relevant, detailed information back."
Key Concepts In LUIS
- Utterance: This is the actual command spoken/written by the User /APP
- Intents: Intents describes the actual intention behind the command given by the user.
e.g. when the User says "Find me all the Push made on the PublicWorks Repository", what user wants is the list of the Push made on the PublicWorks repository, hence Push made is the intent here. - Entity: This is extra information that is present in the utterance which helps the LUIS to understand the utterance more. In above e.g PublicWorks is the name of the repository and hence is the entity which gives the name of the repository on which the Push is to be queried.
Design
The design of the flow can be divided into following subparts.
- Creating LUIS Application
- Registering LUIS app in Azure Portal
- Creating Logic App
Creating LUIS Application
Following are the step by step instructions to create the LUIS application. This LUSI application detects the intent in the Subject line and checks if the mail sender wants to create an issue. If so it will send the intent in the JSON response to the logic app.
Log on to the LUIS portal() using Azure Credentials.
Create a new application which will detect the necessary intents.
Select the newly created application from the list.
Create a new simple entity called RepositoryNameEntity
Create a new intent called CreateIssueIntent
The entities are mapped to the intent for a few utterances as shown below.
Once done, train the application and it can be tested using sample test data. Note that more the training data more intelligent application will be.
This completes the creation of the LUIS application.
Registering LUIS Application in Azure Portal
In order to consume the LUIS app from the logic apps, the LUIS app must be published to the Resource group so that logic app connectors can use it, in order to do so, a LUIS cognitive services account need to be set up in the Azure. Refer to following steps to set up the account
Once an account for LUIS is created, the publication of the app becomes very easy. Navigate to the Publish Tab in the LUIS portal and select the environment (Production/Staging) and the time zone. Click on Add key to publish the LUIS app in the region which has the LUIS cognitive account created above. The details will be auto populated.
Logic App
The logic app is very easy to set up. The logic app will monitor one mailbox on a recursive basis and with the help of the subject and the trained LUIS application will create an issue in GitHub if the subject line indicates so. Once the issue is created the logic app will reply back to the user with details of the issue created.
Following are the steps to create the logic app.
Select the Logic App under integration in the basic blade.
Fill out the necessary details like the name, resource group etc.
Select the blank template to begin the creation of the logic app
from the list of the available triggers select the Gmail:When a new Email Arrives trigger.Configure the gmail connections and set the frequency for the trigger to poll the Gmail inbox.
[
From the List of available actions select the LUIS: Get Prediction action. Connect the Logic App to the necessary LUIS application and provide the Subject from the received email as the utterance.
Initialize a variable to store the entity name.
If the desired Intent value in the response from LUIS prediction is true means that the user has sent mail to create an issue on the repository. Configure the condition action in such manner.
Set the value of the variable using the entity name which can be derived using a ParseJson action.
From the list of available actions select the GitHub:"Create an issue in GitHub". Connect the logic app to the GitHub account and provide details like the owner name, the repository name can be provided from the entity that was parsed in the above step. The description of the issue will be the body of the email received.
Once the issue is successfully created, in order to send out an acknowledgement with the issue details, from the list of available action, select Gmail:ReplyToEmail action. Configure the message id from the details of the mail received and body with the details from the Create Issue action response.
In the false branch, no action is required at all.
This completes the logic app design.
Testing
Following is the request response email communication to and from the logic app. Same issue is created in GitHub also.
Conclusion
From the above design, it can be concluded that it is very easy to set up an intelligent flow to create an issue in GitHub.
See Also
Following links can be visited to learn about some of the applications of logic apps and the readers can try to implement them in Flow.
- Updating Users With Daily Weather Forecasts Using Logic App
- Logic Apps: Face Verification Using Microsoft Cognitive Services Face Api and Logic Apps
- Logic Apps: Optical Character Recognition From Image and Detected Text Analysis Using Microsoft Cognitive Computer Vision Api, Text Analytics Api and Logic Apps
- Logic Apps: Integrating LUIS Application With Logic Apps To Predict Intent in User Utterances
References
Following article was referred to quote information about LUIS.