SendGrid API - Cannot use dynamic template data with a legacy template - twilio

Trying to follow the sample here https://docs.sendgrid.com/ui/sending-email/how-to-send-an-email-with-dynamic-templates,
I'm sending the following JSON to this url: "https://api.sendgrid.com/v3/mail/send" (and I have sent a simple email before using the same code, now I want to try a template with substitution):
{
"personalizations": [
{
"subject": "Test template email from SendGrid",
"to": [
{
"name": "Neal Walters",
"email": "myRecipient#example.com"
}
],
"dynamic_template_data": {
"Applicant_Name": "John Doe",
"Send_Date": "December 30, 2022"
}
}
],
"from": {
"name": "NealWalters(SendGrid)",
"email": "mySender#example.com"
},
"template_id": "bcab1b12-d922-4cdd-b6f5-9f39b16d9823"
}
and getting this cryptic error:
{"errors":[{"message":"Cannot use dynamic template data with a legacy template
ID","field":"personalizations.0.dynamic_template_data","help":null}]}
I have no idea what is a dynamic nor a legacy template. I copied one of Send Grid's demo templates (Nonprofit Newsletter Email Template) and added some of my own tags.
When I used the template name ("NealDemo Duplicate Nonprofit Newsletter Email Template") instead of the GUID (which I got from the URL when I was editing the template), the message was similar but added this to the above error - which leaves me with the question of can I use the template name or not? It's unclear what a "template_id" is on how to find it, if it is not the name of the template as I saved it.
{"message":"The template_id must be a valid GUID,
you provided 'NealDemo Duplicate Nonprofit Newsletter Email Template'.","field":"template_id","help":"http://sendgrid.
com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.template_id"},{"message":"Unless a valid template_id is
provided, the content parameter is required. There must be at least one defined content block. We typically suggest
both text/plain and text/html blocks are included, but only one block is required.","field":"content","help":"http://s
endgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.content"}]}
Disappointed these are not listed on this errors page:
https://docs.sendgrid.com/api-reference/mail-send/errors
Are there two template editors?
I used this one:
https://mc.sendgrid.com/design-library/your-designs/bcab1b12-d922-4cdd-b6f5-9f39b16d9823/editor
I didn't see any other guid/id for the template, so I tried "bcab1b12-d922-4cdd-b6f5-9f39b16d9823" from the URL.
But now I see there is also a dynamic template editor???
https://mc.sendgrid.com/dynamic-templates
As mentioned below, I copied one of your demo templates, which already had some substitution variables in at the bottom ({{Sender_Name}}
{{Sender_Address}}, {{Sender_City}}, {{Sender_State}} {{Sender_Zip}}). I just added two of my own at the top.
I have referenced this: Getting "Cannot use dynamic template data with a legacy template" with non-legacy template
The saga continues. I went to this page: https://mc.sendgrid.com/dynamic-templates and was able to copy over my previous template, so perhaps it was a legacy template. It now gave it a clearly labeled template-id of: d-a35d9d48ce304588bbebf7828811b473 (which looks like a "d-" followed by a guid).
I ran that through the API call, which resulted in no immediate errors, but then I got this email:
Usually when I can't figure things out, it is either the documentation is lacking, or I was speed-reading it.

When I first setup my account, I apparently clicked a link that took me to SendGrid's main site, and I signed up for an account there. Apparently this step was totally unnecessary (also their site requires a 2FA, separate from Azure). So I built my templates on their site, which was under a different account then the one I created in Azure. Thus I was able to send emails with the token from Azure, but any time I tried to send a template from my second account, of course, it was not recognized with my Azure account.
You can create templates inside of Azure, from the links shown below:
Then this:
NOTE 1 - their "pretty" designs are still under the Legacy Templates, and "Dynamic Templates" seem to be the newer preferred way to go. You can build a "legacy template", then apparently copy it's HTML over to a "dynamic template".
NOTE 2 - I only solved this by opening a support ticket with SendGrid.

Related

Twilio IVR flow with translations

I am trying to add multiple languages to my studio flow. 1 - English, 2 - Spanish, 3 - French.
When the user selects the language I am saving the selected lang in {{flow.variables.lang}}. Based on the selected lang, I then load the respective translations.
I have multiple strings which use values set in the previous widget. I am not understanding how to set these values dynamically.
For Example:
String: "Welcome to Studio flow, we found your information in our system with zip code {{widgets.User_Information.parsed.zipCode}}"
In the translation file, I have this string set to key "User_Zip_Code".
In the widget "Gather Input on call" I added {{widgets.Translation_Function.parsed.User_Zip_Code}} in the text to say field. But when the voice reads it out, I expected Twilio would parse the and insert the dynamic value, but it just read it out as is. Is there a way to dynamically insert these flow variables in the string dynamically?
One way I could think of is to call a function and have that function return the string after replacing the values, but for some reason, there are a lot of gaps that I am seeing when the flow moves from one function to another, so I am trying to avoid function calls.
EDIT:
Adding the data shown in the Widget & Flow Properties
"User_Information": {
"status_code": 200,
"content_type": "application/json",
"parsed": {
"zipCode": 201010
},
}
"Translation_Function": {
"status_code": 200,
"content_type": "application/json",
"parsed": {
"User_Zip_Code": "Welcome to Studio flow, we found your information in our system with zip code {{widgets.User_Information.parsed.zipCode}}. Press pound to continue.”
},
}
Thanks in advance
It should work as you explained. Are you sure the reference in the liquid syntax is indeed correct, for example: {{widgets.User_Information.parsed.zipCode}} ?
Try looking at the Studio Flow Execution Logs (under Logs) to see the path you must refer to in the liquid syntax is correct/
Update:
It appears you are nesting Liquid Syntax expressions. What I mean by that is your Gather Input on Call Widget is referencing parsed JSON from an earlier Widget and that JSON has a liquid syntax expression in it.
Example JSON:
"FT_Fee_Information": "We found your account in our XX payment system. As a reminder, payments processed through this system are subject to a $x.xx convenience fee. Payments without a fee can be made through the My Account portal on our website at example.com. If you would like to use the stored payment information to make a payment on account ending in {{widgets.Validate_Number.parsed.accountNumber}}. Please enter the 5 digit zip code associated with this account. If you would like to pay on a different account press the pound key.
I am pretty sure that is the reason for your issue, you can't nest these liquid syntax expression. Instead, can you pass in the Studio data to the Function calling the JSON so that Function can pre-populate this information (static data) into JSON (instead of using a liquid expression) before returning the JSON blob to Studio?

In SAP UI5 `List` the "count-indicator" [ item-N / total-M ] is missing below the "More" button

I'm developing software for 40+ years but I'm absolutely new to SAP UI5, so maybe this is very basic or a trivial problem but half a day of searching the internet brought no results:
In a Master-Detail View (defined in xml) I want to display a list of items with growing=true, growingThreshold=50 and growingScrollToLoad=false as a List.
In principle it got everything working OK now. But there is a tiny glitch, not essential, more in the category of a "nice to have":
All the examples I've seen so far show something like "[ 50 / 107 ]" below the "More" button. But in my program it is missing. I'm very sure the reason is __count is not included in the response sent from the Odata-Service implementation.
Testing directly with the SAP Gateway Service Builder (/SEGW) shows to include the count in the response $inlinecount=allpages needs to be appended to the service URI. And here it works fine - once I add this to the URI the count is included, when I leave it out or set it to none there is no count included.
Therefore the problem seems not to be in the service implementation. (At least the __count field is present or not present as expected. And I assume this is what enables the "[ # / # ]" indicator.)
When the request is then sent from the controller (implemented in JavaScript) this part is not added to the service URI, despite the OData-Model is created with defaultCountMode: "sap.ui.model.odata.CountMode.InlineRepeat". On the "Network" page of Chrome's developer tools I don't see the $inlinecount=allpages appended and also the "[ 50 / 107 ]" (or whatever is appropriate) is not shown with the "More" button.
I checked with the Chrome developer tools immediately after creating the Odata-Model if my setting in the OData-Model takes effect – and it does. And I checked once more before a request is made based on this OData-Model – and it is still there.
My only idea now is it might have something to do with the fact the request originates from the XML-view (ie. the JavaScript code created on behalf of it) and it might be using a different Odata model in which that option is not set.
How can I test for this?
Any other ideas?
Maybe an internationalization issue? (The trigger-text for displaying more entries is set to "Weiter" in German language. Maybe also the "[ # / # ]" parts needs to be re-defined elsewhere too?
The answer in the comment of Boghyon Hoffmann solved the problem:
[Use] defaultCountMode: "InlineRepeat" instead of adding a fully qualified name in string.

Strapi routes return 404 Not found

I have a problem where all routes in my API return 404 Not found. I followed the Pull from Docker Hub section at strapi/strapi-docker.
What I did, apart from running the images, was creating a new Content type called post containing three fields. If I try GET /post (to get all posts added) I get unauthorized response error. This is expected at this stage. After I check Roles & Permissions to allow the Public role to use the find and findOne routes I instead get a 404 Not found response error even though data has been added.
The dev server does not use any prefix.
post routes for find and findOne looks as the following:
{
"routes": [
{
"method": "GET",
"path": "/post",
"handler": "Post.find",
"config": {
"policies": []
}
},
{
"method": "GET",
"path": "/post/:_id",
"handler": "Post.findOne",
"config": {
"policies": []
}
}
}
There are not many options in the strapi interface to fiddle with so I'm not sure what else to try. I have tried a couple of other installations of strapi. Not sure if that could have messed it up but I vaguely remember trying out strapi/strapi-docker before and getting it to work.
I have stumbled upon this issue many times, and the easiest answer usually is:
Have you published any of your posts?
Strapi has a publishing subsystem which is usually turned on upon the creation of any collection, single type or component.
So when you create any content of any created type, the data is saved as draft and is not publicly available.
Here is my link collection type. It is saved, but not published.
So if you are trying to test an endpoint, but you only have one single data entry and it is set to draft, no data will show up.
No data!
In case of a single type that is not published
This will return a 404!
Publish and, voila ...
This could be one reason why strapi is sending you a 404 or only an empty array!
I've had this issue many times as well, even with published content.
Two additional causes could be:
if your content type is posts try /posts as well as /api/posts (the 2nd usually works for me
Under Settings > Roles (the one under USERS & PERMISSIONS plugins) make sure both Authenticated and Public user roles have find and findOne access to the content type.
One time I was getting the 404 even though I did this for Public...but because I was in the same browser as my logged in admin and needed to update it for Authenticated as well.

Cumulocity smarREST response templates

I am trying to set up the Cumulocity smartREST response templates to supply info from the device object stored by an app. I am thinking it is not possible but I want to confirm because the documentation is brief and not clear.
I have successfully implemented MEASUREMENT POST templates previously but I am trying to do INVENTORY GET now. I have set some values in the device object and I can see them from tenant.cumulocity.com/inventory/managedObjects/id/. This could look like:
"custom_values": {
"val1": "abcde",
"val2": "fghij"
}
Now I go to the smartREST template web interface editor and create a template (eg t1) and set a message (eg m001) and set it to 'inventory' and 'get' and tick 'includes response'. I'm not sure if I need custom fields here. Then I create a response (eg r001) and I now have to fill in base pattern with a condition and some number of other patterns. I assume in one of those fields I have $.custom_values.val1 etc but all permutations I try result in 'no access to object' error from topic 's/e'.
My ideal result (from the above example) would be to publish to '/s/uc/t1' with 'm001' and receive 'r001,abcde' (ie custom_values.val1) and publish 'm002' and receive 'r001,fghij' (ie custom_values.val2).
Thanks for taking the time to read.
Your approach is correct but your MQTT user probably is just missing the rights to the object as it is created by the app (I guess the mqtt client is a device user).
The best approach here is to give this object you are creating from the app the fragment c8y_Global
{
"name": "testObject3",
"c8y_Global": {},
"custom_values": {
"val1": "abcde",
"val2": "fghij"
}
}
This fragment will make this object available to all registered users. This is common practice for app meta data.

Using Ruby/rails variables in a mandrill template

Is it possible to use your rails variables on a Mandrill template?
I have an app where a user gets notified via email on certain actions, and right now it's done with action mailer without using Mandrill so it's just a text email with no styling. Obviously, I'd prefer to use a mandrill template I already have to add some dynamic content via variables.. I see a ton of companies using variables in email notifications so i assume it's possible, i just haven't found many useful articles that explain how it's done. If you can point me towards a useful article or just answer the question it'd be really helpful! Right now, I already made the template using Mailchimp, then sent it to mandrill and it's ready for use. My app already has the Mandrill configurations and works properly (i use it for static email that don't include variables). All i really need to do is configure it to allow me to use variables.
Thanks in advance. Happy holidays and war eagle!
One way is to use the merge tags in the Mandrill template, and then either global_merge_vars (all recipients) or merge_vars (per recipients) message options to populate the template.
It is not very exciting approach, but it works fine.
In short, the solution is to put tags like:
*|MYTAG|*
anywhere in the template. Then, the send calls just need to populate the right option. Here for all participants:
mandrill = Mandrill::API.new('my_api_key')
template_name = "my-template-name"
template_content = [] # See doc, not related to the issue at hand.
message = {
to: [{email: 'smith#example.com'}],
headers: {"Reply-To" => "noreply#example.com"},
merge: true,
global_merge_vars: [
{name: 'mytag', content: "Hello, World"}
]
}
mandrill.messages.send_template(template_name, template_content, message)
This should send an email with the tag replaced with the corresponding contents (Hello, World here).

Resources