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 transcript2 Replies
Updating
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
/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:
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:
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.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