I want to send emails to an SMTP server via API call, with attachments (like PDFs, XLSx, etc.).
I already have a function that sends emails to this SMTP Server. This function is a python function on Object.
This function can be called via an Action, so that a user is in front of a Workshop application can click a button, and get the action to trigger, which triggers the function which sends the email and edit the Ontology to store whatever was sent.
Now I want to support the same flow, but with attachments for my emails.
What I’m looking to clarify:
In Action, I can specify an input “media reference”, so I can upload a media directly in my action. Where is this media stored ? In a mediaset ? in a dataset ? temporarily ?
In Function, I need to access the media so that I can send it to the API. Can I read a file from a media reference in a python function ? (I see some docs about attachments reading but not media) Does it needs to be stored in a mediaset ? In a dataset ?
In my Data connection, I assume I will just pass the file in the body of the webhook or handle it directly in my python function. Is there an example of such configuration somewhere ? How does it relates to the media/dataset stories above ?
When you have a ‘media reference’ parameter in an action form, the media will be uploaded to the media set that backs that media reference property (as defined in the capabilities tab). If you have multiple media sets that back that property, the media set it is uploaded to is arbitrarily decided.
You can read a file from a media reference in a typescript function, but this isn’t fully supported yet in python functions. We hope this will be possible in the next few months. There’s a chance that you could use platform SDK endpoints in the meantime. The media would need to be stored in a media set for it to have a valid media reference.
I don’t believe we have an example configuration of passing the file in data connection. When you read a media file (from a media set) in a function, you will get the bytes of the file, so should be able to pass to an endpoint.
And you refer to the “capabilities tab” of the action ? Correct ?
Because an Action might not be tied to one Object Type (e.g. I can have an action that just asks for one media as part of its form, but it’s not storing the media reference to an object at all)
To clarify: “uploaded to is arbitrarily decided” means “always the same, but we can’t know which one” or does that mean “randomly” (like, each time potentially different) ?
I’m referring to the capabilities tab which is in the Object type configuration. An action that specifically uploads to a media set will be tied to an object type. We currently don’t support media upload forms in function backed actions.
In terms of how the media set to upload to is decided, we technically choose the first media set that matches the schema type of the file uploaded, so this could be different if you have different file types. In the future, there should hopefully be functionality to define which media set you would like to upload to