Forum Discussion
arie_schwartzman
Microsoft
Mar 06, 2023Send metadata from Health Bot server to Web Chat client via backchannel.
You can send metadata attached to a message activity from the server side of Health Bot to the client side to be able to trigger various client events and set client properties.
For example, we would like to turn the chat input prompt to be "password" type when we pass the {secret: true} object from the Bot.
You can attach the metadata object that will be sent as part of the message activity in the Prompt/Statement steps.
On the Web Chat client side, modify the code that handles the message activity to identify this metadata passed in the "entities" property and act accordingly. In this example, set the type of the input prompt to be "password" as shown below.
else if (action.type === 'DIRECT_LINE/INCOMING_ACTIVITY') {
const inputType = (action.payload && action.payload.activity &&
action.payload.activity.entities &&
action.payload.activity.entities.find(e => e.secret === true)) ? "password" : "text";
const input = document.getElementsByClassName("webchat__send-box-text-box__input")[0];
if (input && input.type !== inputType) {
input.type = inputType;
}
}
No RepliesBe the first to reply