Pinpoint SMS template doesn't work when overriding default attribute values

0

We are using the Java SDK to send SMS notifications through pinpoint. I created a simple test template that looks like "Test {{foo}}"

In my Java code I add a substitution value for "foo". This all works if I don't specify a default value for "foo" in the template, I get an SMS and "foo" is replaced with whatever real value I specified in the code.

It also works if I do specify a default in the template but don't add any substitution in the code. I get an SMS and "foo" is replaced with the default template value.

However, if I try both I get an error back from the pinpoint API

DeliveryStatus: PERMANENT_FAILURE,StatusCode: 400,StatusMessage: The request contains substitutions in both the templates and the message.

I don't really understand why this is an error condition. My understanding is that I should be able to have a default in the template and it just gets overridden if my message contains a substitution. That's how the docs seem to describe it, and it's how email (but not SMS) templates are behaving for me. What am I missing here? Thanks!

Egor
asked 2 years ago1177 views
1 Answer
0
Accepted Answer

Hi,

Thanks for your patience as we worked with the Pinpoint team regarding your query. The service team have confirmed that this behavior is expected. It is expected to either have a template substitution or message-level substitution, but not both. They also mention that email behaves differently due to historical reasons

The service team also mentions the following:

For the part about the documentation regarding overriding default:

Substitutions -> (map)

The default message variables to use in the notification message. You can override these default variables with individual address variables.

It is probably easier to see that in the send-message doc: https://docs.aws.amazon.com/pinpoint/latest/apireference/apps-application-id-messages.html.

The individual address variables means the address configuration here: https://docs.aws.amazon.com/pinpoint/latest/apireference/apps-application-id-messages.html#apps-application-id-messages-prop-messagerequest-addresses

OR the endpoint configuration here: https://docs.aws.amazon.com/pinpoint/latest/apireference/apps-application-id-messages.html#apps-application-id-messages-prop-messagerequest-endpoints

For the send-user-message, it means the individual endpoint configuration in the user part here: https://docs.aws.amazon.com/pinpoint/latest/apireference/apps-application-id-users-messages.html#apps-application-id-users-messages-prop-sendusersmessagerequest-users

AWS
SUPPORT ENGINEER
Ryan_A
answered 2 years ago
  • Thanks for letting me know. It's unfortunate that SMS works this way, the behavior of email templates is more useful. It lets you specify values when you want, but still have generic default fallbacks in the template for graceful failure. But good to know I'm not doing something wrong, we can perhaps implement defaults in code.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions