setBotAuthTokenProvider
Omnichannel for Customer Service offers a suite of capabilities that extend the power of Dynamics 365 Customer Service Enterprise to enable organizations to instantly connect and engage with their customers across digital messaging channels. An additional license is required to access Omnichannel for Customer Service. For more information, see the Dynamics 365 Customer Service pricing overview and Dynamics 365 Customer Service pricing plan pages.
The bot authentication token provider function, when called with a callback function as a parameter, returns the botAuthUrl
to send the token to the bot and invokes the callback function to set the sign-in card visibility.
Syntax
Microsoft.Omnichannel.LiveChatWidget.SDK.setBotAuthTokenProvider(authTokenProvider);
Parameters
Parameter | Type | Description |
---|---|---|
authTokenProvider | Function | Function which when invoked with a callback function as parameter, returns the botAuthUrl to send the token to the bot and invokes the callback function to set the sign-in card visibility. |
Return value
Bot authentication URL.
Example
Here's a code sample that illustrates how you can pass an authentication token to an Azure or Copilot Studio bot during single sign-on.
const signInIds = [];
window.Microsoft.Omnichannel.LiveChatWidget.SDK.setBotAuthTokenProvider(async (botTokenUrl, callback) => {
const urlSearchParams = new URLSearchParams(botTokenUrl);
const signInId = urlSearchParams.get("state");
if (signInIds.includes(signInId)) { // Ignore authenticated sign-in cards
callback({show: false}); // Hide card
return;
}
signInIds.push(signInId);
const authUrl = ""; // Customer's Authentication API
const authResponse = await fetch(authUrl, method: "POST"});
const {token} = authResponse; // Customer's Auth Token
const data = {
token: "token"
};
const payload = {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(data)
};
try {
const botAuthResponse = await fetch(botTokenUrl, payload); // Posts Auth Token to Bot directly
// Sign in through Bot is successful
if (botAuthResponse.status === 200) {
signInIds.push(signInId); // Track authenticated sign-in card
callback({show: false}); // Hide card
}
if (botAuthResponse.status === 404 || botAuthResponse.status == 202) {
callback({show: false}); // Hide card
return;
} else {
// Other condition handling
}
return;
} catch (error) {
}
callback({show: true}); // Show sign-in card by default
});
See also
JavaScript API reference for live chat SDK
Pass authentication token to bot during single sign-on in live chat
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기