I'm building my own MVC web application using .NET Core and I want to add a chatbot application in my website.
In my point of view, after building an agent in dialogflow, and then I should can use webhook to let my C# application to connect to the agent which already exists and push request to it and get response from the agent.
How can I connect .NET Core client to dialogflow agent which already exists or may be some reference?
It's fairly easy. Follow the instructions below :
Connect to GCP by setting-up the environment variable GOOGLE_APPLICATION_CREDENTIALS. Refer the following code :
System.Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", _CredentialsPath)
:
Use following like code to
Public Function GetResponseTo(whatUserSays As String) As String
Dim textInput As New TextInput, queryInput As New QueryInput
textInput.Text = whatUserSays
textInput.LanguageCode = "en"
queryInput.Text = textInput
_Response = _Client.DetectIntent(New SessionName("newagent-12345", _SessionId), queryInput).QueryResult.FulfillmentText
Debug.Print(_Response)
Return _Response
End Function
where - queryInput contains the text typed by the user.