Using Email in Jupyter Workspace - Python Scripts
Hi All,
I was trying to trigger and send emails from the Jupyter workspaces. I have the list of emails to whom I need to send and I also have the subject and body of the email ready, but I'm not able to connect to the DOMO Notifications Email which is being used by Card alerts and Workflows to send out emails. Is there any way to not use our internal SMTP servers and instead try to use the email which is used by DOMO for notifications.
Best Answer
-
I don't believe Domo has a direct API or method specifically for accessing its email notifications. I have sent emails using pydomo. I downloaded the information from a dataset to do a mail merge with my body. But as you are trying to avoid, it had to use my own smtp server.
** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **1
Answers
-
I don't believe Domo has a direct API or method specifically for accessing its email notifications. I have sent emails using pydomo. I downloaded the information from a dataset to do a mail merge with my body. But as you are trying to avoid, it had to use my own smtp server.
** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **1 -
Hi Arbor, Thanks for sharing your experience. Can you share your code snippet which worked for you using pydomo, it could be extremely helpful for me.
Also, do you have any idea on the domo library that is available in the Jupyter script which we use to get the input/output data? I am not sure if that would help or not, but I feel there might be something that could help us connect to the Notifications EMAIL of domo to be used within the script.0 -
I don't have code to do a merge. But I can show you code for pulling down a domo dataset. And another for sending email.
Set up authentication
Generically its supposed to be something like this for pulling down a dataset.
import requestsclient_id = 'your_client_id'
Get an access token
client_secret = 'your_client_secret'
base_url = 'https://api.domo.com' # Domo API base URLtoken_url = 'https://api.domo.com/oauth/token'
Example: Fetching a dataset
payload = {
'client_id': client_id,
'client_secret': client_secret,
'grant_type': 'client_credentials'
}
response = requests.post(token_url, data=payload)
access_token = response.json()['access_token']dataset_id = 'your_dataset_id'
Process the response
dataset_url = f'{base_url}/v1/datasets/{dataset_id}/data'
headers = {
'Authorization': f'Bearer {access_token}',
'Content-Type': 'application/json'
}
response = requests.get(dataset_url, headers=headers)if response.status_code == 200:
data = response.json()
print(data)
else:
print(f'Failed to fetch dataset. Status code: {response.status_code}')** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **0 -
I hope I'm not including any of my private values in this. {cringe} The comment box reacts to the # symbols and such. So I will paste images.
This code will download a file using the dataset's id set in the variable dataset_id. Id is found in the URL when you open a dataset in your browser. This code uses a Base64 version of the id + secret. Your file path needs to have double backslashes as shown. Replace myFilename.csv with your filename.That basically loads your data for use or saving. The following shows a python routine for sending an email.
The task here is pull the data for use. Cycle through the records for the user list. And use the send_email function to send the emails out as it loops through the records.
** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **0 -
Thankyou so much Arbor. It is going to be really really helpful!
0 -
I'm suspicious of any code that isn't my own. But there's a site that can help with the Base64 conversion if you can't make it happen in your own code.
The following may be useful…
To get the client id and secret for your instance go to developer.domo.com.
Steps for getting the Client ID and Secret- Click on the question mark at lower left corner of your Domo Instance after you have logged in to your Domo Instance
- Click Resources > developer portal
- Click on My account at right upper corner > create a new client and give all permission to that client
- Once you click create client button you will be shown your client Id and secret
** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 753 Beast Mode
- 61 App Studio
- 41 Variables
- 692 Automate
- 177 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive