Add a Personalization
⌛Save time by generating multiple personalized videos with dictionary templates.
Use our API to create dynamic content for multiple audience segments and personalize at scale. Use cases include e-learning, HR training, and client engagement. Personalization parameters can be used to replace content components within a script dynamically. It can be used to automatically generate videos for various audiences simultaneously. For details, please see the example below:
Define a List of Personalization Dictionaries
First, create a list of personalization dictionaries containing a list of variables that will be used in the video. In this example, we will be creating multiple videos where each video contains a different script depending on your_name
, friend_name
, the event_name
, and the event_location
. It will be as follows:
personalization = [
{'your_name': 'Aaron', 'friend_name': 'Yannis', 'event_name': 'Greek Restaurant', 'event_location': 'Wimbledon'},
{'your_name': 'Aaron', 'friend_name': 'Fergie', 'event_name': 'Korean Restaurant', 'event_location': 'Waterloo'},
{'your_name': 'Aaron', 'friend_name': 'Farhad', 'event_name': 'Italian Restaurant', 'event_location': 'Soho'},
]
Develop a Personalization Script
Next, you need to develop a script using the defined variable names surrounded by double brackets as shown below:
script = 'Dearest {{friend_name}}, you are invited by {{your_name}}, and myself, to attend, {{event_name}}, to be held at {{event_location}}.'
The following example shows the full API request to generate multiple personalized videos:
Caution:
Don't forget to replace the placeholder "YOUR_API_KEY" with your unique API key in the header. If you haven't obtained one yet, please contact us at [email protected], and we will provide one as soon as possible.
Import requests
url = "https://api.yepic.ai/v1/videos"
personalization = [
{'your_name': 'Aaron', 'friend_name': 'Yannis', 'event_name': 'Greek Restaurant', 'event_location': 'Wimbledon'},
{'your_name': 'Aaron', 'friend_name': 'Fergie', 'event_name': 'Korean Restaurant', 'event_location': 'Waterloo'},
{'your_name': 'Aaron', 'friend_name': 'Farhad', 'event_name': 'Italian Restaurant', 'event_location': 'Soho'},
]
payload = {
"slides": [{"overlays": [
{
"type": "AvatarOverlay",
"script": "Dearest {{friend_name}}, you are invited by {{your_name}}, and myself, to attend, {{event_name}}, to be held at {{event_location}}.",
"assetId": "1a901a33-8783-418e-af6a-a66dae945673",
"voiceId": "en-US-JennyMultilingualNeural",
"xPosition": 448,
"yPosition": 56,
"width": 1024,
"height": 1024
}
]}],
"personalization": personalization
}
headers = {
"content-type": "application/json",
"Authorization": "YOUR_API_KEY"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
📌 Need help?
Updated 2 days ago