Skip to content

Instantly share code, notes, and snippets.

View dhinag's full-sized avatar

Dhina dhinag

View GitHub Profile
@dhinag
dhinag / MessagesController.cs
Last active September 8, 2018 02:38
Sending the status to citizen
/// <summary>
/// The bot is obviously stateless. When we get the message from D365, we need to parse the data to find out which citizen should receive what message on which channel.
/// </summary>
/// <param name="activity"></param>
private void CommunicateMessageToUser(Activity activity)
{
var message = JsonConvert.DeserializeObject<QueueMessage>(((JObject)activity.Value).GetValue("Message").ToString());
//Conversation ID is generally the key in order to reply to the same conversation in the channel.
if(!string.IsNullOrEmpty(message.ConversationID))
public class QueueMessage
{
public string ChannelID { get; set; }
public string FromID { get; set; }
public string FromName { get; set; }
public string RecipientID { get; set; }
public string RecipientName { get; set; }
public string ConversationID { get; set; }
public string ServiceURL { get; set; }
public string Alert { get; set; }
@dhinag
dhinag / run.csx
Created September 15, 2018 19:49
public class BotMessage
{
public string Message { get; set; }
}
public static BotMessage Run(string queueMessage, out BotMessage botMessage, TraceWriter log)
{
botMessage = new BotMessage
{
Message = queueMessage
user=Joe
bot=LulaBot
bot: Hi!
user: yo!
bot: [Typing][Delay=3000]
Greetings!
What would you like to do?
* update - You can update your account
* List - You can list your data
@dhinag
dhinag / FAQ Template
Last active December 16, 2018 21:06
Portal Web Template to render KB articles in FAQ format.
{% 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>
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);
<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",
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',
{
"modelId": "9f0fb19d-bb84-4c04-a273-b2bf9669cbc0",
"trainingDocuments": [
{
"documentName": "Registration Application1.pdf",
"pages": 1,
"errors": [],
"status": "success"
},
{
@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 {