Skip to content

Instantly share code, notes, and snippets.

View dhinag's full-sized avatar

Dhina dhinag

View GitHub Profile
import argparse
from langchain.agents import initialize_agent
from langchain.llms import OpenAI
import json
from langchain.agents import Tool
from flask import Flask
from flask_cors import CORS
from flask import *
import json, time
//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 };
// 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)
{
styleOptions: {
backgroundColor: 'rgba(255, 255, 255, .8)',
bubbleBackground: 'rgba(0, 0, 255, .1)',
bubbleFromUserBackground: 'rgba(0, 255, 0, .1)'
}
@dhinag
dhinag / Greet user
Last active January 16, 2020 22:26
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>
<style>
html,
body {
height: 100%;
}
@dhinag
dhinag / webchat
Last active January 16, 2020 22:20
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>
<style>
html,
body {
height: 100%;
}
body {
{
"modelId": "9f0fb19d-bb84-4c04-a273-b2bf9669cbc0",
"trainingDocuments": [
{
"documentName": "Registration Application1.pdf",
"pages": 1,
"errors": [],
"status": "success"
},
{
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',
<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",
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);