The Right Approach towards Digital Transformation


In recent years, one of the most discussed concepts in the corporate world by the apostles of change is Digital Transformation. It is the process of redesigning and digitalizing the business model, to make it more competitive in the market, and to improve the value proposition for customers. 

Most of the companies are either at some stage in the transformation process or contemplating it. The global spending on Digital Transformation is projected to touch $2.3 Trillion by the year 2023. But, most majority of these attempts fail, resulting in the wastage of valuable human resources and billions of dollars. There are ways that will help your business avoid the common pitfalls and successfully implement a transformation process.

Power of Why

In the book Start with Why, author Simon Sinek makes the case for the importance of purpose in the functioning of a business. Many businesses face issues at the implementation stage of digital transformation due to a lack of clarity about the purpose and necessity. Leadership should have a clear vision of where they want to take the business. A strong why makes it a lot easier to figure out the ‘what’ and ‘how’. 
‘Our competitors are doing it’ wouldn’t qualify as a solid primary reason for your business to undergo this major overhaul. 

Implementation Roadmap 

Success in any major project relies on your ability to convert your aspirations and ideas into a concrete plan of action. The next step is to make a digital transformation roadmap with clear objectives, milestones, and metrics to measure progress. Keep early milestones to create momentum in the team.

This is the stage where different opinions and priorities among different departments and top executives merge to form the most effective plan. Assigning ownership and responsibilities to various individuals and teams will help maximize the RODI (Return on Digital Investment). You also need to look into the past projects to estimate the project management capabilities of your organization and plan for additional resources if needed.

Business transformation 

Companies like Airbnb, Uber, and Amazon have demonstrated the impact of Disruptive Innovation and emerging technologies like Cloud, AI, Blockchain, Big Data, etc are widely adopted to increase business capabilities. Digital transformation is not meant for small incremental changes or cost-cutting. It redefines all areas of the business model at a deep and fundamental level.

In essence, it is a business transformation with the help of technology. You should use technology as a tool for change, an enabler. So, ignore the hype and noise in the market about new technologies and trends, and select a technology only if it makes sense and fits with your business goals. The transformation efforts should not ruin your core strengths or existing position as a business but build on it. It is like renovating a restaurant while it is running.

Get everyone on Board

In 2014, Automaker Ford made a failed attempt to digitize its business by creating a new section. The reason for the failure was the inability to integrate the digitization efforts with the entire business. 
Many employees think that Digital Transformation is the responsibility of the IT department.

Senior executives might have resistance to the process due to insecurity about the loss of authority or rigidity due to decades of conventional working style. Orientation sessions are needed to educate why this transformation is crucial and how it can benefit the business. All the concerns and doubts should be addressed and cleared at the very beginning of the project.

Innovation Platform and learning culture - 

More than the adoption of new technology, digital transformation needs a change in culture and a fixed mindset. Learning the new trends and innovating has to be ingrained in the DNA of the business. A dedicated innovation team can drive this process of collaboration and sharing knowledge.

This team needs to have a much broader scope than the R&D section and ideally, it should have members from various functions of the business to have a holistic view of the entire value chain. Sometimes, expert consultants might be needed to fill the skill gap. One of the important objectives is to create a Minimum Viable Product (MVP) faster and do the necessary iterations quickly. 

Big Picture

Many successful pilot projects fail at the stage of scaling. So, scalability is a crucial factor to be considered from the very start of the innovation process.

In today’s interconnected world, Industry boundaries are blurring and major companies in tech, financial services, retail, etc are venturing into new fields in the ecosystem. One risk in this scenario is developing a tunnel view and being obsessed with your own business, competitors. It is crucial to have a broader outlook on the industry and the latest developments.

Conclusion 

The competition in the business world is moving towards the pattern of ‘Winner takes it all’. The ability to adapt fast based on the changing circumstances is a crucial survival skill. So, don’t consider Digital transformation as a one time project. Keep it as a continuous process of improvement, building on the past gains, and rooted in a strong technological and cultural foundation.

Drupal is part of many successful Digital Transformation initiatives like the Commonwealth of Massachusetts which has become a single face of government or Pfizer, where the global digital marketing platform is being used in 46+ countries.

At Valuebound, we have partnered with many successful brands in their digital transformation journey using Drupal as well as other open systems. Do connect with us if you would like to discuss the possibility of using Drupal for the next adventure in your enterprise. 

6 Digital marketing Trends for 2020 and Suitability of Drupal


Businesses are allocating a bigger share of their marketing budgets for digital marketing plans. Online marketing initiatives are more flexible and they have better capability to reach the target audience. They add value to the total marketing plan by making it more flexible and controlled. An array of Digital marketing services available in the market provides a level playing field for small businesses to compete with big players, without spending a fortune.

 One major challenge in the Digital world is that successful strategies will be adopted quickly by competing digital marketing companies. So, businesses need to be creative in their strategies and committed to a continual improvement process. 

The main pillar of today’s digital marketing strategy is content marketing. We operate in the attention economy and huge amounts of new content are created on a daily basis. So, it is of utmost importance to manage and make use of your content efficiently. Drupal is a proven Content management system that can help your business to be more flexible and effective in implementing digital marketing strategies. 

According to Dr. Dave Chaffey, author of  ‘Digital Marketing: Strategy, Implementation, and Practice’, there are 6 marketing trends that are going to impact the digital marketing strategies of today’s businesses. Let us see how Drupal is well-positioned to help your business ride the tide. 

Lifecycle marketing

The traditional sales process has undergone significant changes with the prominence of digitalization and the availability of multiple channels. But, the customer journey still encompasses stages of becoming aware, developing interest, comparing and analyzing, purchasing and usage. 
Multiple channels will be involved in this process.

For Eg, a customer might become aware of a gadget through an online Ad, might check the product out in a kiosk, clear doubts with a chatbot on the website, and order using a smartphone. The company has to ensure that all the engagements with the customer at different stages form a coherent and smooth flow, designed to delight. 

To create a consistent experience across the customer journey, we need a platform that can facilitate frictionless communication among various touchpoints. The API-first architecture of Drupal 8, also known as headless or decoupled architecture, allows it to be used as a central web service and interact with a variety of applications to exchange various types of data.

Conversational marketing

Businesses have been doing market research and gathering of customer data for long. Until now, factual information like demographic, age, income, spending, etc. constituted the major chunk of customer data. Still, Marketers did not know much about the motives of the customer or the mental factors affecting his decision making or purchase process. With the introduction of AI, companies are now able to have one on one conversion with customers via smart speakers like Alexa and Echo or through the various web or mobile applications like chatbots. It helps in understanding customer preferences and how marketers can fine-tune their offerings to match their expectations.

Drupal’s developer-friendly architecture, along with the availability of excellent Drupal programmers from one of the largest open source communities, ensures it can be integrated with many modern libraries like Google Assistant or IBM Watson to facilitate conversational interaction.

Insights-driven marketing

We have entered an Era of Data-driven marketing and every element of customer data is captured and analyzed to derive insights to improve the business process. Big Data makes it possible to process huge amounts of Data, to dig deep, and unravel patterns and trends about consumer behavior. Even the analytical tools have evolved over time and can help us better in connecting the dots. 

Acquia, an enterprise open DXP company provides a suite of products including Acquia Profile manager, Acquia Lift and the newly added open CDP, Mautic. These solutions, along with other enterprise products like Google Analytics, Google tag manager, Datalab, etc. help to utilize the power of Data and enable insights-driven marketing to keep up with today's market challenges.

Marketing technology

One of the fastest developing subdomains of Marketing vertical is Martech. Today’s marketer is equipped with an array of tools and technologies for competing in the digital battlefield. Automation is being widely used to free human resources from mundane and repetitive tasks. Tools and technologies are deployed to help in - Information exchanges, Promotion campaigns, email marketing, Search Engine Optimization, User Interface, e-commerce, Social media integration, and numerous other tasks. 

Drupal websites are built with interoperability as a key attribute and several marketing platforms that have dedicated Drupal modules can be easily plugged in. So, marketers can take advantage of multiple platforms simultaneously - for eg, Salesforce or Zoho for CRM, Mailchimp for email campaigns, Hubspot or Marketo for Automation.

Consumer privacy 

Customers are generally wary of sharing personal information, and the failure of Tech giants like Facebook to meet the expectations regarding security has made it worse. Today, there are growing concerns about the use of personal data, and governments across the globe are responding to this by formulating new regulations like the GDPR (General Data Protection Regulation) of the European Union or the latest CCPA (California Consumer Protection Act). Companies like British Airways and Marriott were issued millions of pounds of fine under GDPR for their inability to protect customer data. 

Drupal has understood the concerns and security goals of enterprises and is secure by design. Drupal has a whole security team and a suite of security modules like Encrypt, Key, Field Encryption to protect your system from breaches. Setting up Encryption in Drupal is very easy and thus it helps in protecting small and medium businesses that are normally considered easier targets for attack. 

Digital transformation and marketing transformation

Digital Transformation is the process of restructuring the existing business model to make it more relevant and competitive in the disruption economy. Businesses are adopting emerging technologies and trends like Cloud, AI, Big data, etc. Technology is helping companies for better collaboration among departments, proper monitoring of resource allocation, measuring the effectiveness of projects and initiatives, and faster change management
.

The modular nature of Drupal makes it possible to add only the relevant modules as and when required. It helps in optimizing the functionalities while keeping the system as lean as possible. The easy content creation, coupled with the multilingual capability to drive localization strategy, along with the ability to blend with other technologies make Drupal the ideal vehicle for your Digital Transformation initiatives.  

To sum it up, Digital Marketing shifted from being a separate team for enhancing reach to a collaborative effort among departments to create better experiences for users. Drupal is a preferred platform for Digital marketers because its robust system can scale up according to the increased needs of the market. At the same time, centralized administrative control of the entire system and advanced security features ensure peace of mind. 

Drupal is one of the best open platforms to help marketers to perfectly match the market requirements with business solutions. Get in touch with us to learn more about how Drupal can help your marketing strategies.

How to craft Personalized Digital Experiences using Acquia Lift?

A few decades ago, companies were involved in the mass production of products and services with very limited options for customers to choose from. In the following years, increased competition and technological advancements resulted in the entire process being redefined with Customer Centricity as the core value.

In the digital world, websites and platforms have a huge amount of content and options available for users. The essence of Personalization is to provide the right content, at the right time, to the right person. Businesses like Amazon, Netflix, NewYork Times, etc have successfully used Personalization to create successful customer experience examples.

Acquia Lift

Acquia introduced a marketing solution named Lift in the year 2014. And the Drupal community has helped in fine-tuning it to its latest offering, version-4. Lift uses data to improve the experience for the user and it will result in increased engagement and loyalty. It is a user-friendly tool built for drupal which has the capability to do adaptive targeting. The capabilities and features that make Lift an effective Personalization tool is given below.

a) Profiling and Segmentation - Important User data like location, device type, content preference, etc are captured and analyzed. It helps to create different segments that can be targeted separately using different strategies. For Eg, users from various locations will be viewing different Hero banners that are most relevant for them.

b) Campaigns - Marketing runs on Campaigns and it is easy to create and execute campaigns using Acquia Lift. First, we need to set the objectives and goals for the campaign. A form of the campaign like A/B type, Recommendations or a combination is selected after that. Then the right segments are selected for targeting.


c) Advanced Features

  • Point and Click - To make personalization easier, Lift has introduced a new form without code. So, technical knowledge is not a prerequisite for users to optimize the content.
  • Scheduling- Creating a campaign and scheduling it for a future date or specific event is a feature of Lift that is very helpful when you need to create and run multiple campaigns
  • Live data - Live User data is analyzed to fine-tune personalization and provide the most relevant content.
  • Review - We can view all the active campaigns together and check how each campaign is performing in terms of click-through rate and conversion rate. It is presented in a visual format using graphs.

This video will help you in understanding how we can use Lift effectively for marketing initiatives. 

In today’s business world, there is no discussion on ‘whether to personalize or not?’. Personalization is not a luxury anymore. It is a necessity that businesses need for growth or even survival. Tools like Lift make sure that your content management system and the users blend in perfectly and thus adding value in the process.

It helps your business stay ahead of the curve and provide an omnichannel customer journey to create personalized digital experiences, building a pool of loyal customers. Do get in touch with us to know more about how Acquia Lift can help your business.

How Drupal can help in creating amazing Digital Experiences?

Traditionally, companies used to focus primarily on product designs and features. The underlying assumption was that the best product will automatically bring in the best results. Recently, businesses started developing a holistic view of the customer journey and decision-making process. So, detailed attention is given to Customer experience and how it can be enhanced at each stage. 

In today’s technology-driven world, there are too many entities vying for the customer's attention. Hence, to succeed in the digital world, you should understand the digital customer journey, and design each and every interaction with the customer in a way that results in the best overall digital experience for him.  Let’s examine how Drupal stacks up against the essential attributes of successful digital customer experience for your business. 

Performance Matters 

Nowadays, Customers have very high expectations about performance aspects like loading time, installation time, etc. 

They say it takes a village to raise a child. Similarly, it takes a vibrant community to grow an open-source technology. Drupal benefits from the contributions from the developers and enthusiasts across the globe who always look for ways to optimize the performance. It gives Drupal the capacity to work efficiently even when there is heavy traffic of users. 

Implementation of many performance tools like Redis, Varnish, Memcache or Bigpipe helps in smart caching and it ensures consistent page loading. A plethora of off the shelf CDN services integration options enables the availability of relevant assets based on the geographic location of the user. So, acclaimed companies like Tesla use Drupal for their website.

Feeling of Safety 

In the digital world, businesses gather a lot of data about the Users, directly and indirectly, including very private information, financial information, and proprietary information. And then, there is the constant issue of security threats in the form of phishing, cyber attacks, data leaks, etc. To succeed in gaining the trust of users, companies need to convince them that their privacy is protected with the utmost care.

The strength of a chain is its weakest link. 

Drupal has a dedicated security team of experts from different parts of the globe that focuses on resolving issues. Information about vulnerabilities and solutions are also made available to the community periodically.
Drupal’s security measures meet International standards like OWASP (The Open Web Application Security Project) and that is the reason why numerous Governmental websites like https://www.nasa.gov/ and   https://www.australia.gov.au/ trust Drupal.

Personalization

‘One size fits all’ doesn't work in today’s world where customers expect tailor-made solutions for their challenges. Personalization started initially with a few categories based on color, size, price, etc. Now, it has grown to a level where even minute preferences and concerns of customers are considered and a solution is designed specifically to meet those. Drupal has a robust framework that can manage the varying requirements of different websites and applications.

Acquia offers a new product named Acquia Lift, which is a fast and effective personalization tool. It has a no-code version which makes it easier to use, even for users with no technical background. Besides that, the vibrant Drupal Community has created thousands of contributed modules that help with very specific requirements. For eg, a Smart Content module can be used to deliver segmented content based on options like industry or your target user persona.

Ease of Use

An intuitive UI is needed for customers so that they are not affected by the heavy underlying processes. This requires a flexible system matching the demanding needs of new-age users. Headless Drupal with APIs allows you to work with any modern front end framework like AngularJS, ReactJS, VuJS, NextJS or even other Drupal websites.

Omnichannel

Customers interact with the system through various touchpoints in multiple channels. It is imperative that all the different channels like website, mobile, App, Kiosk, etc should provide consistent information, providing a smooth and enriching digital journey. 

This is especially important for companies engaged in e-commerce as the customer will be accessing information about the products and going through the purchase process through different channels. Drupal can act as the single source of Content which can be managed by various content managers and directed through various channels and touchpoints.  

A closer look makes it evident how the features of Drupal can help in improving the ROI, Customer Acquisition and Retention while being an Open-source platform. Get in touch with us to know more about how Drupal can help your business create spectacular digital experiences for customers.

Creating email templates using custom config entities in Drupal 8

In projects, there are multiple trigger points where emails have to be sent. In Drupal 7, we had the option where we could define a template and set up rules to trigger emails based on defined action.

But the rules module is still under active migration from D7 to D8, and we were short of time to complete the project.

So, we decided to create custom config entities for creating email templates. There was a need to have a configuration page where admin can add new templates having the subject field as well as text body. To help the admin user,  we had to list out all variables available on the same config page. In our case, since the list of trigger actions was pre-defined, we added them programmatically. These actions are available during the email template creation page.

The following steps show how we have implemented it.

Step 1 - Created a custom config entity ‘email_templates’ for the custom module ‘projectname_email_templates’ using the drupal console.

Steps to Generate a custom module using the drupal console:

drupal generate:module
// Welcome to the Drupal module generator
Enter the new module name:
> projectname_email_templates
Enter the module machine name [projectname_email_templates]:
>
Enter the module Path [modules/custom]:
>
Enter module description [My Awesome Module]:
> Module  for email templates
Enter package name [Custom]:
>
Enter Drupal Core version [8.x]:
>
Do you want to generate a .module file? (yes/no) [yes]:
> yes
Define module as feature (yes/no) [no]:
> no
Do you want to add a composer.json file to your module? (yes/no) [yes]:
> yes
Would you like to add module dependencies? (yes/no) [no]:
> no
Do you want to generate a unit test class? (yes/no) [yes]:
>
Do you want to generate a themeable template? (yes/no) [yes]:
> yes
Do you want proceed with the operation? (yes/no) [yes]:
> yes
// generate:composer
Generated or updated files
Generation path: /var/www/html/Drupal_proj/my_proj/web
1 - /modules/custom/projectname_email_templates/projectname_email_templates.info.yml
2 - /modules/custom/projectname_email_templates/projectname_email_templates.module
3 - /modules/custom/projectname_email_templates/tests/src/Functional/LoadTest.php
4 - /modules/custom/projectname_email_templates/projectname_email_templates.module
5 - /modules/custom/projectname_email_templates/templates/projectname-email-templates.html.twig
6 - modules/custom/projectname_email_templates/composer.json
Generated lines: 100

Steps to Generate custom config entity using the drupal console:

drupal generate:entity:config
// Welcome to the Drupal Config Entity generator
Enter the module name [address]:
> projectname_email_templates
Enter the class of your new config entity [DefaultEntity]:
> EmailTemplates
Enter the name of your new config entity [email_templates]:
>
Enter the label of your new config entity [Email templates]:
>
Enter the base-path for the config entity routes [/admin/structure]:
>
Generated or updated files
Generation path: /var/www/html/VB/horse-auction/web
1 - modules/custom/projectname_email_templates/config/schema/email_templates.schema.yml
2 - modules/custom/projectname_email_templates/projectname_email_templates.links.menu.yml
3 - modules/custom/projectname_email_templates/projectname_email_templates.links.action.yml
4 - modules/custom/projectname_email_templates/src/Entity/EmailTemplatesInterface.php
5 - modules/custom/projectname_email_templates/src/Entity/EmailTemplates.php
6 - modules/custom/projectname_email_templates/src/EmailTemplatesHtmlRouteProvider.php
7 - modules/custom/projectname_email_templates/src/Form/EmailTemplatesForm.php
8 - modules/custom/projectname_email_templates/src/Form/EmailTemplatesDeleteForm.php
9 - modules/custom/projectname_email_templates/src/EmailTemplatesListBuilder.php
Generated lines: 269

 

Step 2 - In email_templates.schema.yml (projectname_email_templates/config/schema): Define the variable and its type.

Step 3 - In EmailTemplates.php (projectname_email_templates/sec/Entity) : Define the template entities like entity_keys, config_prefix, admin_permission, links and email templates variables.

Step 4: In EmailTemplatesForm.php projectname_email_templates/src/Form/) we will be creating the required form elements.

Step 5: In the custom module file ‘projectname_email_templates.module’ define a hook_mail() to handle the various trigger points

Step 6: To send emails based on the trigger point, we are using plugin.manager.mail service.
 

Step 7: Drupal views do not support displaying custom config entities. So, In order to list all the email templates created, We are using a drupal custom page with a custom HTML table.


We have created a custom page by creating a route in projectname.routing.yml and creating a controller function 'emailTemplateList' in the AdminPagesController.php

Note: If you want to give access to other than Admin users, we need  Add, Edit, delete and view config entity. we need to give the permission -Administer site configuration (admin/people/permissions)

Get in touch with us to know more about how Drupal can help your in achieving your unique business requirements.

How to create Content type specific Publishing Workflow

We have been working on The Employee Experience Centre project which needed different publishing workflows for a content type used by various departments.

By default, Two modules -Workflow and Content Moderation- are available in Drupal Core which give you one workflow per content type.

In our case, We had another situation. Given the large size of the company, there are multiple departments. And the head of each department wanted to change the content publishing workflow. There would be content in a specific state of workflow. And suddenly, there would be a new directive to create a new workflow. But they wanted to keep following the earlier workflow for content which was already in process.

For this scenario, we had no option but to create a custom module.

  • Default workflow module provides us the moderation state. We created specific state & transition based on the client requirement.
  • Client agreed to define multiple workflows along with states. These were mostly fixed which could be utilized by different departments across the company. So, we created each one using custom code.
  • Then we created a page to enable selection of workflow based on content type. On this page, we created a configuration form to list down all content types and departments. 
  • After selecting a department, we listed down all content types with existing workflows.
  • Workflow can be changed for specific content. This permission was given to very specific roles only.

Routing for configuration form

Workflow configuration form

  • Then in hook_node_presave or in hook_node_update,  we can first check for existing workflow type for content type and department from configuration form. Then, we can set the value of moderation state in node.

// queryCheckExistingWorkflowTypeName service will fetch the workflow type by passing department_name and node type.

We managed to create this work around since project team agreed to have predefined workflow. 

This story is not over yet. Actual requirement was to enable even admin users to create these workflows using configuration page. We are out of ideas on this. Would like to hear your suggestions.

How to Set up Android React Native?

React Native is an open-source JavaScript framework created by Facebook for writing real, natively rendering mobile applications for iOS and Android. It’s based on React and uses Facebook’s JavaScript library for building UI.

Web Developers can write mobile applications that look and feel truly ‘native’, all from the JavaScript library. Just code once and React Native apps are available for iOS and Android.

Why React Native is used
The developer has to write one set of code that is JavaScript code to enjoy the performance of the React Native mobile applications and it will work for both of the platforms, such as iOS and Android. We can reuse React Native components for building both Android and iOS apps. React Native is a great platform for those developers who have expertise in JavaScript as there is no need to learn Android specific Java or iOS-specific Swift. React Native is rapid and UI focused, so it helps to load the app quickly and gives a smooth feel. 

Follow these steps to setup React Native in Ubuntu for Android platform:

1.   Install JDK8 or later versions

sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java8-set-default

2. Download and Install Android Studio into your system.

    Download android studio package using the following link:
      https://developer.android.com/sdk/index.html?source=post_page

 To launch Android Studio, open a terminal, navigate to the android-studio/bin/ directory and execute studio.sh.

launch Android Studio
  2(a. Check if you have a .bash_profile file in your root directory:

         Type ls -a in your terminal and check for the .bash_profile file.

     If you don’t have a .bash_profile in your root directory :

        Type touch .bash_profile

        Open your bash_profile:

        Type nano / .bash_profile

     And add your SDK path:

    if you have a .bash_profile file in your root directory add your SDK path

   Then ctrl + o to write out, hit Enter and then ctrl + x to close the editor.

3. Install Node.js

Sudo apt -get install -y nodejs

4. Install React Native CLI:

npm i -g react-native-cli

5. Create a new React Native project called ‘MyFirstProject’

expo init MyFirstProject
cd MyFirstProject

 6. Start npm server

react-native start

7. Run your project

-  react-native run-android


This is your first screen and your first project in React Native is complete .

react project      

Creating Secure API using Node.js, Express Js and Passport-JWT

Node.js is a server-side platform built on Google Chrome's JavaScript Engine (V8 Engine). It is an open-source, cross-platform runtime environment for executing Javascript code outside of the browser. Node.js is used for developing server-side and networking applications.

  1. Steps for the Installation of Node.js  
    1. For Windows Users 
      1. Go to https://nodejs.org/en/download/
      2. Click on windows-installer.
      3. Now click on “continue” for all the popup screens.
      4. Check the node version by running the command
        node -v
        Check the node version by running the command: node -v
    2. For ubuntu/mac users
      1. The first step is to check node version using the below-mentioned commands

        $ node -v
        Output:
        $ v5.0.0
      2. The next step is to check npm version using the below-mentioned commands

        $ npm -v
        Output: 
        $ 4.0.0
      3. If ‘YES’, then go to the next step; and if ‘NOT’, then Remove node by -
        $ sudo apt-get remove --purge nodejs
      4. Now, Install again using
        $ sudo apt-get install curl
      5. Download node package

        $ curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -
        Note: You can use any version instead of 10.x such as 8.x, 6.x
      6. Lets install NodeJS package
        $ sudo apt-get install -y nodejs
        Check node and npm version using the above commands and make sure it is greater than or equal to the given value.
  2. Create your first simple Node.js project

    1. Create the folder “node-project”

    2. Create file “app.js” in that and add the below code.

    3. Run command “node app.js”
      Run command “node app.js”

    4. It will print “Hello! World” in the command line.

3. Creating Secure API using Node.js, Express Js and Passport-JWT

Express Js: Express js is a web application framework for Node.js. It is a third-party library, used for routing. 

Passport-JWT: This module lets you authenticate API endpoints using a JSON web tokens. It is used to secure RESTful endpoints without sessions.

Npm: It is a ‘Node Package Manager’, basically a command-line tool, as well as a registry for third party library, which can add our node applications.

Steps For Creating Secure Node Api  

 1. Create folder ‘ Node-project ‘ and inside the folder run command

 npm init

it will create the package.json file. This file will contain the details about the project like name, author, version, dependencies and GitHub related items etc.
create the package.json file containing the details about the project like name, author, version, dependencies and GitHub related items etc

 

2. Then, Run the command inside of the root folder.

npm install --save express passport passport-local passport-jwt jsonwebtoken 

Then, check the package.json. It will contain all the above modules.

3. Create file “app.js” and include the installed modules in app.js file using require keyword.

4. Create one more folder called “API” inside the root folder and create a file called user.js and add the following code as shown below:

Creation and Storage of JWT : 

Const token = jwt.sign({ userName: response.userName, userId: response.userId }, "secretekey");
  1. When user logins, first we check wheather user exists in our database or not.
  2. If user exists, then create the token (which will be the combination of the user object and secret key). It is JWT(JSON Web Token).
  3.  It will be stored in the client-side (typically local storage).
  4.  Whenever a user requests to access API, we will pass the token to our middleware function to verify the token is valid or not. If it is valid, only then we will allow accessing our API endpoints.

 

5. Now add the lines to our “app.js”

app.get('/login', user.login);

6. Now create one more folder called middleware, and inside middleware folder create file passport.js. In passport.js add the following code.

Here, I am using the passport-jwt strategy. Once the token is stored in the client-end while accessing our API, we call this function and decrypt the token using the “secret key” and again we check whether user exists in our database or not. If it exists, it will return the user object as a response and then it will call our API endpoint. If the user does not exist, then it will show the error “Unauthorised”.

7.  Then include this file to our app.js . i.e

require('./api/middleware/passport')(passport);

8. Create one function and fetch all user data in user.js. Add the below-mentioned code.

9. Then add our middleware passport-jwt in app.js.

passport.authenticate('jwt', {session: false})

10. While accessing our api /userData,it will call the middleware. If the token is valid, only then, it will allow accessing the getAllUsers function in user.js or else it will show the error as “Unauthorised”

Adding Custom field in search results for Decoupled Drupal Architecture

Nowadays, most of the sites we are working on are built on decoupled Drupal approach. A decoupled website opens up multiple opportunities. Along with new opportunities, we also get our fair share of challenges. One was where I was tasked to create the module, which can take input (string & filetype) from the front end framework and result the dataset along with metadata e.g. image, date, content type and  File Type.

Before we move on with how we implemented this, we need to understand how search function operates in Drupal site. It has three main parts - Source, Index and Results.

Source refers to any kind of content we have on the website. We parse the content and store the metadata in the index. And we display the result in the front-end.

In our case, the front end was built using AngularJS.

First, we had to Identify the schema in which all of our source data was stored. 

The required search page had a basic set of features like title, description, taxonomy, link and some extra metadata like image, date, type and file type. Since we search across multiple sites, we also needed information about the source from where the item comes from.

I created a custom module to create API which can be used for content search like a REST resource using _controller POST method. 

Below is a basic module to explain how we can create Search API to be consumed by the external applications.

We would need to create files as per the below structure.

customapi_search/

├── customapi_search.info.yml

├── customapi_search.routing.yml

└── src

    └── Controller

        └── SearchAPIController.php


Step 1.  Create module.info.yml file to define the metadata of the module.

Step 2. Create search routing file customapi_search.routing.yml

Additionally, create a customapi_search.routing.yml file in which we can define our path (endpoint), controller and methods.

Step 3. Create a SearchAPIController.php Controller file in which we can define custom _controller with [POST] resources.

In our case, we have used the controller method as rest API using POST method, which extends ControllerBase class and EntityQuery used for fetch data precept to the POST method param value.

Endpoint of Custom search api: /api/content-search

Json query parameters like:

{"q": "test", "firstResult": 0, "numberOfResults": 1000, "filters": {"type": ["page","pdf",”docx”]}, "sortBy": "latest"}

The above module will provide endpoint

Endpoint response output:

Changing of Cloned Reference values while Cloning the Entity in Drupal 8

Recently, I came across a unique situation in Employee experience portal project that I was working on.

As in any enterprise, there were multiple departments in the company generating content for specific departments with varying levels of access as well as security.

To increase synergy as well as collaboration between departments, they had decided to allow authors to clone content from different departments. This was also to enable them to reutilize the design layout as well as content created by others.
 

We realized that this is not an option available within the Drupal ecosystem. We do have an  Entity Clone module available. But it was not solving our issue. The challenge was that we needed to clone an entity which was having existing references and these values should be changed in cloned entity based on certain conditions e.g. security groups assigned to a specific department.

These references were paragraphs, widgets as well as other custom entity types. If we clone the node using create duplicate function, it creates a duplicate node. But then, we have to attach all the field definition from the original node manually.

Challenge was in the entity clone process

  • Base field definitions are already available from the original content. Original content is referencing to existing entities.
  • While creating the duplicate, we have an ID (of an entity) only which is not saved yet and we are trying to attach that definition to newly created duplicated content.

Because of this, the content was not being saved with the new modified value.

We found a workaround by reviewing the entity clone module process further.

During the Entity clone process, it saves the duplicate node twice

  • At first, it creates an exact duplicate of the original content and saves it. On saving, ID gets created and then, attach all the reference fields.
  • And it saves the 2nd time with all the references of original content.

We have modified the references of cloned content while saving it the 2nd time. And we have implemented necessary business logic to modify the references.

The following snippet will help in understanding the solution.

 

To perform any alter operation, we have to implement hook_presave

$entity gives you clone entity during entity clone process.

$original_content gives you the values from parent content from where we are initiating the clone of the new content.

Now, you can implement your business logic inside hook_presave to modify the cloned node reference field value.

With the above code, we can change the clone reference values while cloning the entity. I would love to learn from others if there are any other ways to implement the same.

Download the Drupal Guide
Enter your email address to receive the guide.
get in touch