Querying Application insights logs from Application / NodeJS - node.js

i'm trying to make requests to Application insights logs from a Node JS application / API.
I'm trying to find information on how i can from NodeJS make query to Application insights and return information in a API call.
For example
I have an API "AddUser", i'm currently logging in Events the API request in Application insights, where we are tracking information about that request, (Name of user, who performed the API call, timestamp).
If possible, i want to be able to make a query to Application insights to fetch the information (Name of user, etc..) and be able to store this / return this in a separate API.
From the logs in Function app logs i'm performing queries like this:
Function app logs query
So ideally, i would like to do something like initiate a Application insights client in nodeJS, create a query, "where customDimension.body contains "addUser, timestamp(1d)".
Fetch the resulsts in Json or similar, and modify results and return this in a API.
Thanks in advance, sorry if this is confusing x).

Related

How to query an Elasticsearch based API with nodejs

I need to query this API: https://docs.art.rmngp.fr/#search I have a react app where I was planning on making HTTP requests to this API but I haven't been able to perform a search. My question is how to go about doing this? Do I need to make a server to query this API? or what the architecture would look like.
How would you query this API https://api.art.rmngp.fr/v1/ with nodejs.

How to store and get http form data in Azure Insights for Azure Function app

We have Azure Function app (v.4) with post api calls to some external rest resource. I can see occasional failures in Azure monitoring (Azure Insights), but everything I was able to collect in Logs is external api endpoint url (Path like https://... when you open dependencies) with the request get parameters. In order to troubelshoot the failure I need to collect Form data as well for post requests. I wonder how easy it would be, like as easy as setting some flag in azure configuration or modifying app and writing tracing logs explicitly.
The App Insights -> Transaction Search in the portal will show the requests and trace messages but it will only indicate that the function made a HTTP POST call, the response code and duration of that call, it will not show the payload details, so the function app explicitly need to log those details as TRACE info using ILogger instance that is injected to the function.

Edit request in js before sending it to fullfillment endpoint

I need to edit request before sending it to endpoint.
Using Web Demo integration I'm able to send request to the endpoint.
But I can't edit the request in order to provide some extra data to request. Extra data is stored in localStorage so I need to do this in javascript.
I've already connected the agent to an endpoint that handle the request using fullfillment. The problem is that request misses data I can retrieve only from the browser. From fullfillment I can set headers and basic auth but statically and it is not enough.
So I need to add a step in request building/sending:
User write or tell something to embedded chat (Web Demo integration)
Dialogflow recognize intent, params, generate the request.
Additional step: Update the request in javascript
Forward cutomized request to the endpoint
Maybe it's not possible using Web Demo integration. In Documentation can't find a way to just send string or audio in order to receive the generated request.
First of all you will need a custom chat integration, not the default Dialogflow one. Something like Smooch or Kommunicate. The default web demo should only be used for testing your bot. There is NO way you would want to use that in a production environment.
I would save whatever is in the local storage in a database such as Firestore. Once that data is in the database you can use it to modify your request in your fulfillment.
So what I would do:
Have a way to identify a user and save its local storage to the database (as soon as someone clicks on your chat window or opens the chat window)
Once an intent is triggered you check which user is contacting you (through the way that you identified the user) and get all data from the database
Request the data in your fulfillment server
There is no other way in which this is possible. You can't change requests before your query hits Dialogflow.

how can we do logging of conversation messages in database in ibm watson using node.js

I have created a watson conversation using assistant-simple github repo in node.js and it is working fine locally and in ibm cloud also. Now I want to log these conversation messages in a database. How can I log these conversation messages using database in node.js.
Assistant will keep the messages in a log for a small period of time List logs for a workspace and see Log limits.
Alternatively you will have to code putting messages into a database inside the NodeJS (or other language) server Orchestrator layer (which the UI communicates with). This layer gets all the user messages and Assistant responses and so can store them where you want.
I am not aware of a sample which directly communicates with Assistant and stores the user messages in a database. You would need to take various pieces of code and put them together to achieve this.
For example this sample shows how to upload information to a Cloudant database running on IBM Cloud, using NodeJS.
Alternatively if you don't want to write the code locally, you can invoke App Connect to store the data in a database. This Assistant and App Connect sample shows how to use Assistant actions to invoke AppConnect at some point in the dialog flow, either from the Assistant service (using a Cloud Function) or from the Orchestrator layer (as a client action).
The sample passes a user Id found in the utterance, but the approach is to take some data from Assistant, invoke App Connect and pass it to App Connect, and App Connect calls some other external system with the data. In your case, the data could be the user utterance and Assistant response, and App Connect could store this in a database.
One option would be to leverage cloud functions to make a call to another service.
Depending on what you want to do with the conversation data. If you wanted to access chatlogs and metrics you could send it to a logging service such as www.chatseer.com so you can access the logs.

Chatbase API to get analytics data?

We are using Chatbase for multiple clients that we identify with a different version number.
See my previous question here: Track multiple context for the same Bot
We have a dashboard for all those clients and would like to show them their own data. A bit like Google analytics allows it.
So:
Is an API in the pipeline (I couldn't find any existing resources)
If not, in what alternative way could we get the data to present it?
We have a .csv export that is currently limited to the first 500 rows of your message variations report. It is on our roadmap to increase the scope of this report, however there is no official timeline for release.
Our recommendation for deploying an integration like you described in your message is as follows:
Have the user create a Chatbase account in order to obtain the API key
Have the user integrate their analytics on your platform by providing the API key
Send the messages from their bot to their Chatbase API
Provide the user deeplinks to the Chatbase reports from within your UI
Alternatively, you could configure your bot to send a redundant message to an internal database, or bigquery table to have access to all of your logs.
If you would like access to data you have sent to Chatbase up to this point, please contact chatbase-support#google.com and provide your bot's name and/or api key and we can provide a one-time export.

Resources