Attachment SendGRid

Hey @Pete_Hartnett,
Thank you for answering me. It sounds very good for me.
I will test this and keep you informed.
Have a great day,

Hey @Pete_Hartnett,
One more thing please, do you have an idea about integrating twilio (To send SMS to external Tulip users) with Tulip?
thank you for your help,

Hey @FahdERM -

Yes absolutely- Check out this (How to Use Our REST APIs | Twilio) document for more information about their SMS API. I will throw together a quick video about how this can be setup on the Tulip side in a few days.

As a rule of thumb when looking at these documents, I usually look for the “Curl” example code, because that will be the most similar to tulip Connector functions.

Pete

Hey @Pete_Hartnett,
Thanks for the docs.
I will check this out and tell you the result.
best regards,

Check out this thread @FahdERM

Hope this helps!
Pete

Hey @Pete_Hartnettn,
Can you please paste here you Request body of the Send Email with attachment please ?
image
thanks,

Hey @FahdERM -

Sure! Here is the body I was using:

{
   "from":{
      "email":"pete.hartnett@tulip.co"
   },
   "personalizations":[
      {
         "to":[
            {
               "email":"pete.hartnett@tulip.co"
            }
         ],
         "dynamic_template_data":{
            "recip_name": "$sendName$"
          }
      }
   ],
   "attachments":[
        {
          "content": "$Attachment_b64$",
          "type": "application/pdf",
          "filename": "my_file.pdf",
          "disposition":"attachment"
          }
   ],
   "template_id":"d-1e3285264cca4b43a3bf6c5632516d09"
}'

The template_id will differ to match the template ID you find in sendgrind, along with any dynamic template data.

Pete

1 Like

Hey @Pete_Hartnett,
Thank you for your help. I have tested the whole solution and it worked perfectly. Just one more thing, can i edit the custom widget “File encoder” to be able to get the file name and extension type and store them in a variable that will be used in the SendGrid connector?
best regards,

Sure!

There is work going on to make this connector something that can be downloaded directly from the Tulip Library (Tulip Library | Frontline Operations Platform).

Here are the changes to my connector-

The changes to the custom widget (attached below)-

  1. I reworked how we parse the base64 text to support most if not all variable types.
  2. I allowed the file explorer to open any filetype
  3. I changed the output to an object that includes both the base64 and the filename and content type.

And the changes to the send trigger-

Hope this helps-
Pete
customWidget-File Encoder V2.json (3.2 KB)

Hi @Pete_Hartnett,
Thank you for this version of the emailing application. I have tested it and it works perfectly.
But what would great, if it’s possible of course, is that the custom widget could extract the name of the file automatically when the customer attach it to the widget.
Have a great day,
best regards,

Sure!

Check this out. App side and connector side doesn’t change!
customWidget-File Encoder V3.json (2.9 KB)

Pete

Hey @Pete_Hartnett,
Is it possible to send many attachments using this SendGrid connector or i have to send elements one by one?
thanks for your help,
best,

Hey @FahdERM -

Totally. The “Attachments” property in the SendGrid connector function is actually a list:

"attachments":[
        {
          "content": "$Attachment_b64$",
          "type": "application/pdf",
          "filename": "my_file.pdf",
          "disposition":"attachment"
          }
   ],

What this means is you can pass multiple files to it with additional file upload custom widgets.

"attachments":[
        {
          "content": "$Attachment_b64$",
          "type": "application/pdf",
          "filename": "my_file.pdf",
          "disposition":"attachment"
          },{
          "content": "$Attachment2_b64$",
          "type": "application/pdf",
          "filename": "my_file2.pdf",
          "disposition":"attachment"
          }
   ],

Short of some more Custom Widget work there isn’t a super elegant way to support an unknown amount of attachments. (in this case we would need to build the list in the custom widget and pass the entire list as one text object tot he widget).

Hope this helps,
Pete

Hey @Pete_Hartnett,
So if i have correctly understood, i have two ways to do this : 1st is using many simple widgets and modifying the connector or to modify the custom widget and to use the same connector? right?
If the second method is much more simplier, can you please paste me the new code to be used?
thanks for your help,

Hey @FahdERM -

Sorry about the delay, was out of office yesterday.

Attached is another version of that widget. I removed the send button, and instead its output can just be set to variable, then those variables can be sent to the connector. This can be extended to support multiple attachments with multiple copies of the custom widget all feeding to 1 send button.


Hope this helps.
Pete
customWidget-File Encoder V4.json (3.2 KB)

1 Like

Hey @Pete_Hartnett,
Thank you for the solution. I will test it and tell the customer about it and keep you informed if i have other questions about it.
Best regards,

1 Like

A Base64 encoder function in expression editor can be great for binary files management. (G-Code, pictures, pdf, cad, …)

Hey @youri.regnaud -

Recently wrote a feature request for this. The early determination is that we would rather just support files natively throughout the product and abstract away file encoding. The only real case where I have run into a need for b64 is when working with connectors, but this is something we could support natively. You set up the connector with a file type input, maybe adjust its encoding, and then on the app side you pass it an image variable or file variable. Same deal with the return of connectors.

As we move towards supporting more external vision offerings (for stuff like anomaly detection) this need has become more frequent. As far as I know this work hasn’t yet been put on the roadmap, but it is absolutely something we are thinking about.

Pete

Perhaps you can send attachment file from Tulip using SendGrid API by SMTP Relay or Web API v3.

@Pete_Hartnett
is it possible to get this .json file for r.267 too?

Thanks
Chris