Skip to main content

Working with template translations

You can localize your messages by translating them into the language most used by your audience through Falu's message templates. This way, you can ensure that your content is not just relevant but also accounts for nuances, particularities, attitudes, and values.

Think about it: If you are targeting the Tanzanian market with an SMS marketing advert urging the public to visit Kenya's Mount Kenya and your sale price is listed in Kenya Shillings, you have all but guaranteed their lack of interest.

note
  • Template translations are currently only available through the API. You, therefore, need to create or update a template through the API to add its language translations.
  • You can add a translation to any ISO-recognized language by including its three-letter code to your templates.

Add translations to Falu templates

You can add language translations when either creating or updating message templates.

Add translations when creating a template

Create your template as follows:

curl -X POST 'https://api.falu.io/v1/message_templates' \
--header 'Authorization: Bearer YOUR_SECRET_KEY' \
--header 'X-Falu-Version: 2022-09-01' \
--header 'Content-Type: application/json' \
--data '{
"alias":" ",
"description":" ",
"body":" ",
"translations":{
"language1_ISO_code":{
"body":" "
},
"language2_ISO_code":{
"body":" "
},
"language3_ISO_code":{
"body":" "
}
}
}'

Add translations to an existing template

If you have an existing template with no previous language translations, you can add a translation using the PATCH call below:

curl --location --request PATCH 'https://api.falu.io/v1/message_templates/TEMPLATE_ID' \
--header 'X-Falu-Version: 2022-09-01' \
--header 'Authorization: Bearer YOUR_SECRET_KEY' \
--header 'Content-Type: application/json' \
--data '[
{
"path":"/translations/desired_language_ISO_code",
"op":"add",
"value":{
"body":" "
}
}
]'

On the other hand, if you want to update an existing translation in a template:

curl --location --request PATCH 'https://api.falu.io/v1/message_templates/TEMPLATE_ID' \
--header 'X-Falu-Version: 2022-09-01' \
--header 'Authorization: Bearer YOUR_SECRET_KEY' \
--header 'Content-Type: application/json' \
--data '[
{
"path":"/translations/existing_language_ISO_code",
"op":"replace",
"value":{
"body":" "
}
}
]'
note
  1. Check Update a message template API doc for more operations parameters to use in your API requests when patching a template.

  2. Your token names must be similar in the original template as well as in all the translations. For example, Hello {{name}} in English must translate to Hujambo {{name}} in Swahili.

Sending a translated message

Once a template has all the desired translations, you can use it to send a message in any of the defined languages. To do so, make a POST call to the endpoint https://api.falu.io/v1/messages:

curl --location 'https://api.falu.io/v1/messages' \
--header 'X-Falu-Version: 2022-09-01' \
--header 'Authorization: Bearer YOUR_SECRET_KEY' \
--header 'Content-Type: application/json' \
--data '{
"to":"+254SOME_NUMBER",
"template":{
"id":"TEMPLATE_ID",
"language":"language_ISO_code",
"model":{
"key":"value"
}
},
"stream":"STREAM_NAME"
}'