Send an email to a dynamic group using workflows
Is there a way to send an email to a domo group using workflows?
I see there's sendDomoEmail which allows you to create a list of email addresses, sendDomoEmailToPeople which allows you to create a list of domo users, sendEmail which allows you to send to a single email address, and sendDomoEmailToPerson which allows you to send an email to a single domo user but there isn't a sendDomoEmailtoGroup.
You can add a group to the sendDomoEmailToPerson but when you run the dataflow it doesn't send any emails; I'd assume due to the workflow looking in the wrong place to reference email addresses.
I've considered extracting email address from the People dataset based on members of a group but I'm not a smart man and can't seem make a list act as a variable in order to make that work.
Thank you in advance for your help
Best Answers
-
@Jarren - I have good news for you! The code below will do what you're after. This will be added to the global packages soon. See the screenshot for how the inputs should look.
async function sendDomoEmailToGroup(
recipients = [],
subject,
body,
attachments,
) {
const parameters = {
subject,
text: `
<div style="display: flex; flex-direction: column; font-family: Helvetica; overflow-x: hidden; flex-wrap: wrap; width: 100%; text-align: left;">
<div style="display: flex; flex-direction: column; justify-content: flex-start; width: 100%">
${body || ''}
</div>
</div>`,
recipientsGroupIds: recipients.map(Number),
dataFileAttachments: attachments,
};try {
await codeengine.sendRequest(
'post',
'/api/social/v3/messages/domoWrapperNew:plainText/send?route=recipients&method=EMAIL&recipients=',
{parameters},
null,
null,
);
return true;
} catch (error) {
console.error(error);
return false;
}
}async function sendEmailToGroup(group, subject, body, attachments) {
return await sendDomoEmailToGroup([group], subject, body, attachments);
}0 -
Huge shoutout to @DanHendriksen for taking some time to walk me through this. I used the code he provided above and created a new package. One small line of code that didn't get copied over was defining 'codeengine'. He scheduled a call with me, provided the missing code (const codeengine = require ('codeengine');), and made sure everything worked out as it should.
Thanks @DanHendriksen
1
Answers
-
We're going to enhance the function to include group support soon.
For now, you would need to run the fetchGroup function in the Domo Groups package, then create a list of persons from the list of ID's returned and email to that list of persons.
Does that make any sense? LOL
0 -
@DanHendriksen For the kids in the back of class…is there a resource that helps explain how to create a list of persons from the returned ID's?
0 -
@Jarren - I have good news for you! The code below will do what you're after. This will be added to the global packages soon. See the screenshot for how the inputs should look.
async function sendDomoEmailToGroup(
recipients = [],
subject,
body,
attachments,
) {
const parameters = {
subject,
text: `
<div style="display: flex; flex-direction: column; font-family: Helvetica; overflow-x: hidden; flex-wrap: wrap; width: 100%; text-align: left;">
<div style="display: flex; flex-direction: column; justify-content: flex-start; width: 100%">
${body || ''}
</div>
</div>`,
recipientsGroupIds: recipients.map(Number),
dataFileAttachments: attachments,
};try {
await codeengine.sendRequest(
'post',
'/api/social/v3/messages/domoWrapperNew:plainText/send?route=recipients&method=EMAIL&recipients=',
{parameters},
null,
null,
);
return true;
} catch (error) {
console.error(error);
return false;
}
}async function sendEmailToGroup(group, subject, body, attachments) {
return await sendDomoEmailToGroup([group], subject, body, attachments);
}0 -
To answer your question though, the "fetchGroup" function will return a list of all the people in that group, including their ID's. Then you can define the objects and set ID as a person. The code above to email the group directly is far simpler though.
0 -
Thanks @DanHendriksen
So…I'm going to need some hand holding here since I'm not as smart as you.
I use fetchGroup with input "BAC Group" which creates the output "group". This generates the following object data:
{
"group": {
"id": 1806246612,
"name": "BAC Group",
"type": "closed",
"userIds": [
1496850857,
162776153
],
"creatorId": 1496850857,
"memberCount": 2,
"guid": "2a5334dd-21d4-11ef-b054-0aedcedcc725",
"description": "",
"hidden": false,
"default": false,
"active": true
}
}So then I define the object but the group object doesn't have have any children
So I choose to add a child and call it userids and set it as person
Then I add the sendDomoEmailToPeople since it uses the userIds as recipients
But the variable needs to be a List (Person) type and not just a Person type for some reason. So I figure if I can extract the userIds as a list I can later define it as a List (Person). I've tried just about every package available in DOMO Object Utilities, DOMO List Utilities and DOMO General Utilities to extract this list of userIds but always end up with a NULL value.
Obviously I'm missing something. Can you break down this process for me so a five year could understand it? You can borrow my crayons.
0 -
@Jarren - I think you're being too hard on yourself, and I apologize that I didn't explain it better. Did you see my other comment? If you create a new package in Javascript, paste that code, set the inputs up as I show in my screenshot and set the outputs up as a boolean you're in business. It will work, will work flawlessly and will require fewer actions in your workflow.
If you want to take the initial approach I suggested before the function I shared above was written, as you've tried in your post, your next step would be to write a custom function that removed the userIds child from your object and returned it as a list of persons.
I'm happy to show you exactly how to write that function if you want, but if you're going to be creating a custom function anyways then you might as well just use the one I posted above. Happy to setup a quick call with you to go over this too. Shouldn't take more than just a couple of minutes and happy to set aside 15-30 to help you out. Dan.Hendriksen@Domo.com0 -
To answer the last part of this, for some silly reason the product doesn't let you define an object to include a list. You were doing everything right…in your first attempt to define the object if we allowed you to say it was a LIST of persons then you would have been golden, but for some reason the product doesn't allow you to stipulate that it's a list. So it tries to return a string/person/whatever and there's a list there so it fails.
You could use the "Get List of Text from Object" on the Domo Objects package, but then you'd have a list of strings where your subsequent shape wants a list of persons, so you'd need to run a conversion function.
Far better to just use the code I shared to create a package that sends an email to a group. Like I said, I'm totally happy to hop on and walk you through it. Lord knows I needed a lot of help the first many times I did it, as I'm far from an engineer or coder.0 -
Huge shoutout to @DanHendriksen for taking some time to walk me through this. I used the code he provided above and created a new package. One small line of code that didn't get copied over was defining 'codeengine'. He scheduled a call with me, provided the missing code (const codeengine = require ('codeengine');), and made sure everything worked out as it should.
Thanks @DanHendriksen
1
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 738 Beast Mode
- 57 App Studio
- 40 Variables
- 685 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 47 Workflows
- 10 DomoAI
- 36 Predict
- 15 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 124 Manage
- 121 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive