Skip to content

Instantly share code, notes, and snippets.

Avatar

Dhina dhinag

View GitHub Profile
View Notify Controller
//This action is called by the Power Automate
[HttpPost]
[Route("postReview")]
public async Task<IActionResult> PostReview(string activityId, string botId, string conversationId, string serviceUrl, string userId, string channelId, string botName)
{
var convRef = new ConversationReference();
//Revive the conversation reference
convRef.ActivityId = activityId;
convRef.Bot = new ChannelAccount { Id = botId, Name = botName };
View Conversation Reference
// Invoked when a conversation update activity is received from the external Azure Bot Service channel
// Start a Power Virtual Agents bot conversation and store the mapping
protected override async Task OnConversationUpdateActivityAsync(ITurnContext<IConversationUpdateActivity> turnContext, CancellationToken cancellationToken)
{
AddConversationReference(turnContext.Activity as Bot.Schema.Activity);
await s_conversationManager.GetOrCreateBotConversationAsync(turnContext.Activity.Conversation.Id, _botService);
}
private void AddConversationReference(Bot.Schema.Activity activity)
{
View custom message bubble
styleOptions: {
backgroundColor: 'rgba(255, 255, 255, .8)',
bubbleBackground: 'rgba(0, 0, 255, .1)',
bubbleFromUserBackground: 'rgba(0, 255, 0, .1)'
}
View Greet user
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>
<style>
html,
body {
height: 100%;
}
View webchat
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>
<style>
html,
body {
height: 100%;
}
body {
View trainmodel
{
"modelId": "9f0fb19d-bb84-4c04-a273-b2bf9669cbc0",
"trainingDocuments": [
{
"documentName": "Registration Application1.pdf",
"pages": 1,
"errors": [],
"status": "success"
},
{
View Backchannel.liquid
renderWebchat();
async function renderWebchat()
{
const store = window.WebChat.createStore({}, ({ dispatch }) => next => action => {
if (action.type === 'DIRECT_LINE/CONNECT_FULFILLED') {
dispatch({
type: 'WEB_CHAT/SEND_EVENT',
payload: {
name: 'webchat/join',
View HomeWebtemplate.liquid
<div id="webchat" role="main"></div>
<script src="jso.js"></script>
<script src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>
{% if user %}
<script>
var config = {
client_id: "b31-aced-b61e18a4f68a", //The client id that was generated when registering the bot app in AD.
redirect_uri: "<portal_url>", //Your portal home page url
authorization: "<portal_url>/_services/auth/authorize",
View BotAuthentication.cs
using(var httpClient = new HttpClient())
{
// Set headers
httpClient.Timeout = new TimeSpan(0, 2, 0); // 2 minutes
httpClient.BaseAddress = new Uri(_serviceUrl);
httpClient.DefaultRequestHeaders.Add("OData-MaxVersion", "4.0");
httpClient.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
// Use the bearer token here
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenResponse.Token);
@dhinag
dhinag / FAQ Template
Last active Dec 16, 2018
Portal Web Template to render KB articles in FAQ format.
View FAQ Template
{% fetchxml KB_Query %}
<fetch version="1.0" mapping="logical">
<entity name="knowledgearticle">
<attribute name="knowledgearticleid" />
<attribute name="title" />
<attribute name="content" />
<order attribute="title" descending="false" />
<filter type="and">
<condition attribute="isrootarticle" operator="eq" value="0" />
</filter>