Working with template translations

Define a template and use it to send multi-language messages


You can localize your messages by translating them into the language your audience uses through Falu's message templates. This way, you can ensure that your content is relevant and 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 guaranteed their lack of interest.

Add translations to Falu templates

You can add language translations when 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":" "
    }
}
]'

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"
}'