Ask Your Question
4

How can the ThingsBoard Rule Chain be utilized to gather all the email addresses of customer users?

asked 2021-09-03 11:00:00 +0000

lakamha gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-02-22 05:00:00 +0000

lalupa gravatar image

To gather all the email addresses of customer users in ThingsBoard using the Rule Chain, you can follow these steps:

  1. Create a new Rule Chain in ThingsBoard.
  2. Add a 'Data Converter' node to convert the incoming payload into JSON format.
  3. Add a 'Filter' node to filter the incoming payload and only process messages that contain customer user data.
  4. Add a 'Script' node to extract the email addresses from the payload and store them in a variable.
  5. Add a 'Function' node to store the email addresses in a database or send them to an external system.

The script in the 'Script' node can look something like this:

var emailAddresses = [];
var users = msg.payload.users;

for(var i=0; i<users.length; i++){
  if(users[i].isCustomer){
    emailAddresses.push(users[i].email);
  }
}

msg.emailAddresses = emailAddresses;

The 'Function' node can then store the email addresses in a database or send them to an external system using an HTTP request or email integration.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-09-03 11:00:00 +0000

Seen: 9 times

Last updated: Feb 22 '23