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!

1 Respuesta
0
Respuesta aceptada

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
INGENIERO DE SOPORTE
Ryan_A
respondido hace 2 años
  • 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.

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas