If your application needs to hand off to a live agent provider, you will need to handle the hand-off activity. You can learn more at Bot Framework Direct Line API. use new directLineClient to communicate to your botĪfter starting a conversation with the bot, the conversation JSON payload uses the standard Microsoft Bot Framework Direct Line activity. create a new directline client with refreshTokenĭirectLineClient = new DirectLineClient(refreshToken) String refreshToken = new DirectLineClient(currentToken).Tokens.RefreshToken().Token Requires the currentToken valid when refreshing The following example uses samples from the Connector sample code to refresh the token for an existing Power Virtual Agents conversation: // DirectLine provides a token refresh method The token expires but can be refreshed before it expires learn more at Direct Line Authentication. You may need to add code to refresh the Direct Line token if your application has a lengthy conversation with the bot. String.Equals(x.From.Name, /*Bot_Name*/, StringComparison.Ordinal)).ToList() List botResponses = response?.Activities?.Where(x => To display bot response only, filter equals to your bot name response contains set of Activity from both user and bot response from bot is of type .ActivitySetĪctivitySet response = await (conversationtId, watermark) More information about watermark is available at To get the first response set string watermark = null Using (var directLineClient = new DirectLineClient(token)) Use the same token to create a directLineClinet You can filter response activities by your bot's name to get only the bot's response message. The retrieved Direct Line response activities contains both the user's and bot's messages. Retrieve the bot's response using the same token and converstaionId. UriBuilder uriBuilder = new UriBuilder(TokenEndPoint) using (var httpRequest = new HttpRequestMessage()) The following example uses samples from the Connector sample code to get a Direct Line token for a Power Virtual Agents bot. If the request is successful, a Direct Line token will be returned for the requested bot. To request a Direct Line token, issue a GET request to the endpoint below: GET /api/botmanagement/v1/directline/directlinetoken You need to add code that retrieves a Direct Line token with the Bot ID and Tenant ID from the previous section to your app. To start a conversation with your Power Virtual Agents bot, you need a Direct Line token. You'll need this in the Get Direct Line token step. In the navigation menu under Settings, select Channels. To connect to the bot you have built with Power Virtual Agents, you'll need to retrieve your bot's name and token endpoint to identify it.Ĭopy your bot's name in Power Virtual Agents. Retrieve your Power Virtual Agents bot parameters Contextual variables available upon hand-off.The instructions in this document reference the following: Code samplesĬode snippets used in this document are from: It is intended for experienced IT professionals, such as IT admins or developers who have a solid understanding of developer tools, utilities, and IDEs. Instructions in this section require software development from you or your developers. Select the Mobile app tile to open the configuration window.Ĭopy the code under the Web-based apps section and provide it to your app developers to add to your web-based app.Ĭonnect your bot to a native or custom app In Power Virtual Agents, in the navigation menu under Settings, select Channels. A bot created in Power Virtual Agents that you want to connect to your app.Learn more about what you can do with Power Virtual Agents.Both procedures are described in this article. However, both web-based apps and native or custom apps still require considerable developer expertise to fully integrate the bot into your app. There are different procedures for connecting to your mobile app, depending on whether your app is a web-based app or a native app.Ĭonnecting your bot to a web-based app is relatively straightforward as it involves copying a code snippet into your app. In most cases, your custom app will be a mobile-device app that is either a web-based app or a native app or adapter to other services that your business requires. You can connect your bot to a custom app so that the app's users can interact with the bot directly from within your app.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |