human handoff bot sample not running - c#

I was trying to run this github bot framework sample but I am getting error.
I have configured Bot on Bot Framework Portal, add botID, AppID, AppPwd in web.config, enabled Directline, configured ngrok.
As soon as I am opening index.html page I am getting following error.
JavaScript critical error at line 83, column 32 in
http://localhost:3979/agentdashboard/index.html?s=DIRECTLINEKEY\n\nSCRIPT1002:
Syntax error
Any idea whats wrong?

JavaScript critical error at line 83, column 32 in http://localhost:3979/agentdashboard/index.html?s=DIRECTLINEKEY\n\nSCRIPT1002: Syntax error
I checked the JavaScript code written in index.html, and I find that the arrow function expression are used. Such as:
const connect = () => {
var name;
if(!connected)
name = "connect"
else
name = "disconnect"
botConnection
.postActivity({type: "event", value: "", from: user, name: name})
.subscribe(connectionSuccess);
};
If you are using the browser that does not support it, which will cause Syntax error.
Same error in Internet Explorer:
Please refer to Browser compatibility of Arrow functions, and browse index.html in the browser that supports arrow function expression to check if it works for you.

Related

Error: Twilio.Exceptions.AuthenticationException: 'Username can not be null'

I'm trying to create a Twilio app in C#, I took the code on the official documentation. I installed all the packages that the doc ask, for and try to run the app, but the following message error appears:
Code:
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Types;
TwilioClient.Init(
Environment.GetEnvironmentVariable("********"),
Environment.GetEnvironmentVariable("********")
);
var message = MessageResource.Create(
from: new PhoneNumber("whatsapp:********"),
to: new PhoneNumber("Whatsapp:********"),
body: "Test"
);
Console.WriteLine("Message SID: ", message.Sid);
Error:
Unhandled exception. Twilio.Exceptions.AuthenticationException: Username can not be null
at Twilio.TwilioClient.SetUsername(String username)
at Twilio.TwilioClient.Init(String username, String password)
at Program.<Main>$(String[] args) in
line 5
I tried to implement the code line that appears in the error message, but the error is still there
Code:
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Types;
TwilioClient.Init(
Environment.GetEnvironmentVariable("*********"),
Environment.GetEnvironmentVariable("*********")
);
Twilio.TwilioClient.SetUsername(
username: "*********#gmail.com"
);
Twilio.TwilioClient.Init(
username: "*********#gmail.com",
password: "*********"
);
var message = MessageResource.Create(
from: new PhoneNumber("whatsapp:*********"),
to: new PhoneNumber("Whatsapp:*********"),
body: "Teste"
);
Console.WriteLine("Message SID: ", message.Sid);
Something important to mention is that I create and set my account on Twilio, so everything is all right
This happens when I debug:
Debug
Please try the following code snippet:
Set Twilio Account SID (String Identifiers at Twilio) as username twilio.com/docs/glossary/what-is-a-sid and
Set Twilio Auth Token as a password
var sid = "34digitSID";
var authToken = "authToken";
TwilioClient.Init(sid, authToken);
For security reasons we can save this in appsettings.json file in asp.net MVC and read it as follows:
var sid = Configuration.GetValue<string>("AppSettings:Twilio:AccountSID");
var authToken = Configuration.GetValue<string>("AppSettings:Twilio:AuthToken");
TwilioClient.Init(sid, authToken);
Twilio tutorials and samples will usually use environment variables, but you have to make sure you set the environment variables first.
This is to avoid hard coding sensitive information like Account SID and Auth Token, which could then be accidentally committed to source control.
You're currently passing null to the first parameter of TwilioClient.Init which is why the error occurs. The reason that you're passing null is that the environment variable you're trying to pull isn't configured yet.
If you're running your .NET project from the .NET CLI, before running the project, configure the environment variables like this:
If you're using a bash or bash-like shell (mac/linux/unix):
export TwilioAccountSid=[TWILIO_ACCOUNT_SID]
export TwilioAuthToken=[TWILIO_AUTH_TOKEN]
If you're using PowerShell:
export TwilioAccountSid=[TWILIO_ACCOUNT_SID]
export TwilioAuthToken=[TWILIO_AUTH_TOKEN]
If you're using CMD:
set "TwilioAccountSid=[TWILIO_ACCOUNT_SID]"
set "TwilioAuthToken=[TWILIO_AUTH_TOKEN]"
Once you close your shell, the environment variables are lost and you'll need to set them again next time.
If you're not running the project from the CLI, but from an IDE, the IDE may also let you configure environment variables, but depending on the IDE, it may be stored in a plain text file inside of your project, which introduces the same risk of accidentally putting it into source control and leaking the sensitive tokens.
You can also set environment on Windows, profile or system wide using their built-in UI.
Lastly, the samples use Environment Variables because they are universally available (on all OS's and infrastructure) and are the simplest way to safely get started, but .NET has a much better way of configuring applications.
Here's an article that will take you from using environment variables to the .NET Configuration Builder and some of its features.
PS, let us know how you're running your project, like what IDE, what shell, etc. and also what Operating System you're using, so we can provide more specific instructions.

Bot framework emulator not working

I started learning bot framework last week, and i decided to start off with the default bot project that returns your input and its number of character. But unfortunately, I couldn't test the bot application in bot emulator. It can't just send my input. It displays "couldn't send" whenever I forward an input.
My endpoint url which is http://localhost:3979/api/messages/ is correctly written there.
What could be wrong? I'm just a starter in bot framework and bot building.
As I'm not aware of the exact code which you are trying to execute, I'd suggest few points to be checked again.
Checkpoints:
Make sure you are running the code in debug mode with any browser (Edge, chrome, explorer etc.) and then run in the emulator.
Configure or link the emulator with ngrok. (Though it is not required when running locally but it may resolve if the emulator is not working with firewall issues)
Please check the Microsoft App Id and Microsoft App Password are the same in emulator and Web.config file.
Try with blank Microsoft App Id and Microsoft App Password in both Web.config file and emulator.
Check if the endpoints on the browser and emulator are the same
If you are encountering other errors like 401, 405, 500 please check this article.
In case if all the check points are right and you are still encountering an issue while running the code in emulator, there might be an issue with the code or reference libraries. You can also check the working example.
Check your visual studio .bot file. It should be like this.......
{
"name": "EmulatorBot",
"description": "",
"services": [
{
"type": "endpoint",[enter image description here][1]
"endpoint": "http://localhost:3978/api/messages",
"name": "EmulatorBot20181123022900",
"id": "25"
}
],
"padlock": "",
"version": "2.0",
"path": "C:\\Users\\suraj.tiwari\\Desktop\\Bot NK\\EmulatorBot\\EmulatorBot.bot",
"overrides": null
}
Add an Endpoint for your bot
Endpoint url : http://localhost:3978/api/messages
Name : EmulatorBot20181123022900

How to solve "Qt: Could not initialize OLE (error 80070005)" issue

I am using Rotativa to generate PDF in my Application. It's working fine in my application localhost (Development). I got the "Qt: Could not initialize OLE (error 80070005)" error once, i have deployed in my server. How to solve this issue. Thanks advance
Go to IIS > Site > Authentication, click on "ASP.NET Impersonation" and DISABLE it
I found the problem here-
https://github.com/wkhtmltopdf/wkhtmltopdf/issues/2782
We started by removing all assets (css and javascript) from the document - leaving just images and the html layout. It generated correctly through IIS. We then slowly added back resources, starting with CSS. The moment we added one of our Javascript files back it threw the OLE error again. We removed that and added some simple Javascript to the document (literally var x = 1;) and it still failed.
For some reson wkhtmltopdf cannot find js files...
so i found the solution here-
https://github.com/wkhtmltopdf/wkhtmltopdf/issues/1634
I simply had to change:
<script src="//cdnjs.cloudflare.com/ajax/libs/numeral.js/1.4.5/numeral.min.js"></script>
to:
<script src="http://cdnjs.cloudflare.com/ajax/libs/numeral.js/1.4.5/numeral.min.js"></script>
(added the HTTP).
I also switch on server from ActionAsPdf to UrlAsPdf
And set the url to localhost
string pthx = "http://localhost/Home/exmple?num=" + numtofind;
UrlAsPdf urlss = new UrlAsPdf(pthx) {
FileName = "REPORT.pdf",
CustomSwitches = "--print-media-type "
};
I think the wkhtmltopdf can't find host...
Hope it will help you too...

Mathematica .Net/Link in an Asp.Net application

I am using the Mathematica .Net/Link platform to create a web service to format and calculate math problems. However I am unable to get it working.
I create it using this code:
_Log.IpDebug("Starting the Kernel Link");
if (string.IsNullOrEmpty(_MathLinkArguments))
_InternelKernel = MathLinkFactory.CreateKernelLink();
else
_InternelKernel = MathLinkFactory.CreateKernelLink(_MathLinkArguments);
_Log.IpDebug("Kernel Link Started");
_InternelKernel.WaitAndDiscardAnswer();
The value of _MathLinkArguments is -linkmode launch -linkname \"C:\\Program Files\\Wolfram Research\\Mathematica\\7.0\\Math.exe\".
This piece of code is called from the Application_Start method of the global.asax.cs file.
When it gets to the WaitAndDiscardAnswer() call it gives the server error:
Error code: 11. Connected MathLink program has closed the link, but there might still be data underway.
Note: The SampleCode given with the .NET/Link package (both a console app and a WinForms app) works.
Edit:
I copied the console app sample code given with Mathematica into an asp.net page and it gave me the same error the first load and then on subsequent loads it gave me:
Error code: 1. MathLink connection was lost.
Edit2:
I forgot to mention that when I have procmon and task manager open while running my app, I can tell that Math.exe starts but it immediately exits, which makes those error code make complete sense...but doesn't explain why that happened.
To allow the .Net/Link to work in Asp.net (at least in IIS 7.5) you need to enable the property loadUserProfile on the app pool for the web site.
I am not entirely sure why this is the case, but from what I found while trying to debug this, there are some things that are gotten from the user's profile. I know for a fact that the default location of the kernel is, which explains why I couldn't use it with no arguments, and so I can only assume that other things are needed as well and without the profile it couldn't determine that.
But whatever the reason is this is required, it is, or at least it is a fix if you are getting similar problems like this in your own application.
I got the same error in a .Net WinForm application.
mathKernel = new MathKernel();
mathKernel.Compute("<< XYZ`XYZGraphs`");
The error occurred on loading the package straight after instantiating the MathKernel.
To resolve it you can wait a couple of seconds and then instantiating the MathKernel works fine. During this state where there might still be data underway the following conditions are both false:
if (!MathKernel.IsConnected)
{
MathKernel.Connect();
}
if (MathKernel.IsComputing)
{
MathKernel.Abort();
}
Edit:
I've recieved the error again and this time was able to determine the problem.
Using a command line open the MathKernel.exe and view the error message:

ASP.NET FaceBook App Development -

I have downloaded both samples for the Facebook Developer Kit from Codeplex and Facebook.NET followed both tutorials down to the word - But as soon as I browse to me app on Facebook I am getting the following error for BOTH versions?
API Error Code: 100
API Error Description: Invalid parameter
Error Message: Requires valid next URL.
Anyone else had this problem? I'm struggling to find an answer to what the error actually means? Especially as the starts kits are supposed to work out the box?
You need to disable data permissions.
Settings > Migrations > "New Data Permissions" > Disabled

Categories