explorium
explorium4h ago

How do i set user metadata for Transcripts?

I have added this code on my app after the user logging in: await axios.patch( ${VOICEFLOW_API_URL}/state/user/${email}/variables, { email, tenantId, tenant }, { headers: { Authorization: VOICEFLOW_API_KEY, 'Content-Type': 'application/json' } } ); the request success but i dont see the user metadata on the transcript
2 Replies
Tico | Voiceflow Assistant
Updating /state/user/{id}/variables only stores those values inside your assistant’s runtime – they’re available to your flows, but they aren’t copied into the Transcripts UI.
The fields that appear at the top of every transcript (user name + avatar) are written when the transcript is created, not from runtime variables. There are two ways to populate them: • Web-chat embed – include a user object when you load the widget:
window.voiceflow.chat.load({
verify: { projectID: 'YOUR_PROJECT_ID' },
url: 'https://general-runtime.voiceflow.com',
versionID: 'production',
userID: email, // becomes sessionID
user: {
name: email, // what you want to see in Transcripts
image: 'https://…' // optional avatar
}
});
window.voiceflow.chat.load({
verify: { projectID: 'YOUR_PROJECT_ID' },
url: 'https://general-runtime.voiceflow.com',
versionID: 'production',
userID: email, // becomes sessionID
user: {
name: email, // what you want to see in Transcripts
image: 'https://…' // optional avatar
}
});
The widget automatically saves the conversation and the user object is shown in Transcripts. • Custom backend / DM-API flow – after (or during) the conversation call the Transcripts API yourself:
await axios.put('https://api.voiceflow.com/v2/transcripts', {
projectID: 'YOUR_PROJECT_ID',
versionID: 'production',
sessionID: email, // must match the DM-API userID
user: { name: email }
}, {
headers: { Authorization: VF_API_KEY }
});
await axios.put('https://api.voiceflow.com/v2/transcripts', {
projectID: 'YOUR_PROJECT_ID',
versionID: 'production',
sessionID: email, // must match the DM-API userID
user: { name: email }
}, {
headers: { Authorization: VF_API_KEY }
});
You can also later PATCH /v2/transcripts/{id} to update that metadata. So keeping the await axios.patch('/state/user/.../variables', …) is fine for internal logic, but to see the metadata in Transcripts you need to supply it through one of the two routes above.
explorium
exploriumOP4h ago
i have tried this solution: class VoiceFlow { static initAndIdentify({ email, tenant, tenantId }) { // Check if VoiceFlow is already loaded if (window.voiceflow) { console.log('VoiceFlow already initialized'); return; } // Create and load the VoiceFlow script const script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'https://cdn.voiceflow.com/widget-next/bundle.mjs'; script.onload = () => { if (window.voiceflow) { window.voiceflow.chat.load({ verify: { projectID: '<id>' }, url: 'https://general-runtime.voiceflow.com', versionID: 'production', voice: { url: "https://runtime-api.voiceflow.com" }, userID: email, user: { email, tenantId, tenant, } }).then(() => { window.voiceflow?.chat.proactive.push( { type: 'text', payload: { message: 'Hey!' } }, ); }); } }; // Insert the script into the document const firstScript = document.getElementsByTagName('script')[0]; firstScript.parentNode?.insertBefore(script, firstScript); } } export default VoiceFlow; but i still dont see the user on the metadata

Did you find this page helpful?