This is the third post in a five-part series on how I integrated a Raspberry Pi with Microsoft Dynamics CRM to recognize contacts using automobile license plates. Although the code samples are focused on license plate recognition, the solution architecture I used is applicable to any Dynamics CRM + Internet of Things (IoT) integration. In my previous post, I showed how I set up my Raspberry Pi to capture images and parse them for license plate numbers. In today's post, I will show how to trigger the license plate recognition process and then use the extracted license plate number to find a contact in my Dynamics CRM organization with a custom workflow activity.
As I described in part 1 of this series, this approach uses a web resource, a dialog or some other interactive mechanism to call a custom workflow activity that instructs the Raspberry Pi to take a picture and return the parsed license plate number. The code hosted in CRM then searches for a contact with the returned license plate number and displays its details to the user. This requires that the CRM server be able to communicate with the Raspberry Pi, which may be challenging for CRM Online deployments.
The custom workflow assembly
Interacting with the Node.js web page just requires making a GET request and then parsing the JSON response, so the approach to working with JSON data in custom workflow assemblies that I've used in several other posts will work great for this.
There are only a few changes required to that sample:
- Modify the JSON response classes to match the JSON object returned by the Node.js application.
- Modify the web request to be a GET instead of a POST.
- Add logic to search for contacts by license plate number and return the contact id as a string.
- Update the input/output parameters to return the contact, license plate and image details.
The code for the custom workflow assembly is available in my Crm-Sample-Code repository on GitHub here
One thing to keep in mind is that because I wanted to register the assembly in isolation, I had to create a hosts entry for my Raspberry Pi on my CRM application server since sandboxed assemblies cannot make web requests to IP address URLs. Alternatively I could have created an entry on my LAN DNS server.
The custom CRM action
The web resource
Finally a web resource is used so the user can interactively trigger the license plate recognition and open the contact record if a match is found. The web resource also displays the image that is captured by the Raspberry Pi so the user can validate that the license plate number extracted by OpenALPR matches the actual license plate number.
The web resource (lpa_checkplate.htm) is included in my sample CRM solution along with the custom action, compiled plugin and contact entity configured to store the license plate number. The sample CRM solution is available in my GitHub repository here.
Here's the web resource open a new tab.
Here's the result after I click the "check plate" button. The contact name is a hyperlink that will open the contact record in a new window.