Tuesday, April 17, 2018

Dynamics 365-Twitter Integration


Dynamics CRM always need integration with multiple system integration.
Basically, Dynamics CRM sales and marketing module always looking for more integration with social sites like Facebook, Twitter, LinkedIn etc.
 In my last project there was a requirement to integrate Dynamics CRM Marketing Campaign with Twitter. When organization create any new campaign/promotion organization need to spread tweet about that, so customer know about their campaign and promotions.
Here, I will tell how you can integrate your Dynamics 365 with Twitter.

Step1: - Create Application in Twitter. I will demonstrate how you can create application in Twitter.

Open given URL https://apps.twitter.com/ in browser and login with our organization twitter account.















Now click on “Create New App”. And provide your application details. In website textbox enter your company web address. If you do not have any web address, use can also use CRM online address. Make sure your web address should be accessible via web. Any local website will not work.






















Now click on “Create Your Twitter Application”.
























Now my Application is created with Consumer Key. We also need Access Token to complete our application. So, click on “Create my access token” button.
Now copy your Consumer Key (API Key), Consumer Secret (API Secret), Access Token, Access Token Secret keys and save for future use. Also make sure Access level should be “Read and Write”.
Now our first step is completed.

Step 2: - Create Custom Workflow.

We need to create custom workflow to send Tweet from Dynamics CRM.
Open visual studio and create a class library project


















Right click on project and select “manage nuget package” and write TweetSharp in search bar.
Now click on install button. It will TweetSharp.dll in your project.

















Now we need to pass keys at runtime, so we need to create input arguments for Keys and our message that needs to tweet.
Create new object of TwitterService class. And call SendTweet method.
Add signature to your project. And build the solution.
Now My custom workflow is created.

Step 3: - Create a Merged assembly.

In our custom workflow we have used external assembly to call twitter. So, we need to merge all assembly in single assembly.
We have multiple option to merge assembly in single assembly. But my favorite tool is https://ilmergegui.codeplex.com/ .
Download and install this ILMerge UI.































Open ILMerge and click on “Add assembly” and select three dependent assembly and one your custom workflow assembly.



















Now select your custom workflow assembly. Mark check “Sign with key file” option and select your project signing key. Also provide output location of assembly. Than click on “Merge” button.
Now your final assembly is created.

Step 4: - Register your assembly in Dynamics CRM/365.

Now are ready with our assembly. We just need to register this in Dynamics CRM/365 and start playing with this.
If you are using new version (9.0 or higher) of Dynamics 365 old Plugin registration tool will not work.
Now register your assembly.















Now our assembly is registered.

Step 5: - Create workflow in Dynamics CRM/365.

Login to your Dynamics CRM organization and create new process.
I am using Campaign entity to send tweet. Make sure your tweet field should not have text length greater than 280.
I am also using Campaign Status Details field (Status Reason) = “Launched” to send tweet.


















Now provide your Keys details that we stored in step 1. You need to provide key information in your custom workflow calling step.
Activate your workflow.

Step 7: - Send Tweet from Dynamics CRM/365.

Create a new campaign. Enter your promotion needs to tweet. Select status reason as “Launched”.















Save the record and check your tweeter account. You will see new tweet there.

No comments:

Post a Comment

Get files of last hour in Azure Data Factory

  Case I have a Data Factory pipeline that should run each hour and collect all new files added to the data lake since the last run. What is...