Send Whatsapp from Message bird in ASP.net - messagebird

We have an application in VB.Net which currently send a pdf via automatic email on certain event done in application. Now we want to send the PDF in whatsapp via messagebird api. Below is a sample from messagebird
Dim WhatsAppClient As Client = Client.CreateDefault(YourAccessKey)
Dim language As HsmLanguage = New HsmLanguage()
language.Code = "en"
language.Policy = HsmLanguagePolicy.Deterministic
Dim params As List(Of HsmLocalizableParameter) = New List(Of HsmLocalizableParameter)()
Dim hsmParamName As HsmLocalizableParameter = New HsmLocalizableParameter()
hsmParamName.Default = "Bob"
Dim hsmParamWhen As HsmLocalizableParameter = New HsmLocalizableParameter()
hsmParamName.Default = "Tomorrow"
params.Add(hsmParamName)
params.Add(hsmParamWhen)
Dim hsmContent As HsmContent = New HsmContent()
hsmContent.Namespace = HsmNamespace
hsmContent.TemplateName = "verification"
hsmContent.Language = language
hsmContent.Params = params
Dim content As Content = New Content()
content.Hsm = hsmContent
Dim request As ConversationStartRequest = New ConversationStartRequest()
request.To = [To]
request.Type = ContentType.hsm
request.Content = content
request.ChannelId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Dim message As MessageBird.Objects.Message = WhatsAppClient.StartConversation(request)
I am getting errors in "request.Type = ContentType.hsm" "HSM is not a member of string"
and in last line -
Value of type 'MessageBird.Objects.Conversations.Conversation' cannot be converted to 'MessageBird.Objects.Message'
Any push in the correct direction will help. Thanks

Looking at the MessageBird SDK I can see that https://github.com/messagebird/csharp-rest-api/blob/752b809245a72674dadf469b6f9641dcf697a4e7/MessageBird/Objects/Conversations/Content.cs the call should be
request.Type = ContentType.Hsm
Here is an example of it https://github.com/messagebird/csharp-rest-api/blob/0c5bbd13736e9f0fb1719246232698d8039915ad/Examples/Message/SendTemplatedMessage.cs
On your last error, the startConversation signature is as follows as per https://github.com/messagebird/csharp-rest-api/blob/0c5bbd13736e9f0fb1719246232698d8039915ad/MessageBird/ConversationsClient.cs:
public Conversation StartConversation(ConversationStartRequest startRequest)
This may explain the error you are seeing.
Couple of questions:
Are the above compilation errors?.
Where did you get the example you have illustrated above?.

Related

How to use SuppressGetDecimalInvalidCastException in vb.net

With some vb.net code I try to retrieve data from an Oracle database (simplified example):
strQuery = "Select 2.3, 2.3/1, 2.3/3.1 From Owner.TableName Where ROWNUM < 10"
Dim da As OracleDataAdapter
da = New OracleDataAdapter(strQuery, ConnectionString)
da.Fill(GetData)
This results in an "Specified cast is invalid" error.
The 2.3/3.1 is the problem.
I learned from "Specified cast is not valid" when populating DataTable from OracleDataAdapter.Fill() that Oracle works with a higher precision than dot net can handle and that I should use SuppressGetDecimalInvalidCastException in the OracleDataAdapter. But I don't know how to code it in VB.net. Can anyone help me?
Automatic translation from the C# code did not work.
The C# code itself did not work for me (probably due to the fact that I don't know how to handle the async stuff) and if I simplify it to
string queryString = "Select 2.3, 3.1 From owner.table";
string connectionString = "Data Source=Data.plant.be/database;User ID=****;Password=****";
var table = new DataTable();
var connection = new OracleConnection(connectionString);
var command = new OracleCommand(queryString, connection);
var adapter = new OracleDataAdapter(command) {
SuppressGetDecimalInvalidCastException = true
};
adapter.Fill(table);
I get error CS0117: OracleDataAdaptor does not contain a definition for SuppressGetDecimalInvalidCastException.
Extra info:
As proposed by #Andrew-Morton - thank you Andrew - I wrote:
Dim table = New DataTable()
Dim connection = New OracleConnection(ConnectionString)
Dim cmd = New OracleCommand(strQuery, connection)
Dim adapter = New OracleDataAdapter(cmd) With {.SuppressGetDecimalInvalidCastException = True}
adapter.Fill(GetData)
But I get BC30456: SuppressGetDecimalInvalidCastException is not a member of 'OracleDataAdapter'.
Remark: I have version 19.6 of Oracle.ManagedDataAccess.
I could not install package 'Oracle.ManagedDataAccess 21.9.0'. I Get: You are trying to install this package into a project that targets '.NETFramework,Version=v4.5', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

How to asdd call attrs. after the call droped just like mark done button?

I am able to add call attrs using 'Genesyslab.Platform.Voice.Protocols.TServer.Requests.Userdata.RequestAttachUserData' when the call is online but how to do when the call is dropped?
I found this in WDE
void SelectDispositionCodeSetAttachedData(string dispositionCodeValueName);
//
// Summary:
// Update or add the keys of the specificed KeyValueCollection in the attached data
// of the interaction . The current list of attached data can then be retrieved
// using GetAttachedData. If the interaction media type is 'voice' or 'instant message'
// and the interaction is not released the added/updated values are immediately
// committed to T/SIP Server. If the interaction media type is 'voice' or 'instant
// message' and the interaction is released the added/updated values are sent to
// T/SIP Server as a UserEvent when the interaction is marked done (programmatic?aly
// or by Agent). If it is an eServices interaction (e-mail, chat, etc.) and the
// interaction is still handled by the agent the added/updated values are immediately
// committed to Interaction Server. After e-Services interaction is released, no
// further programmatical update is committed to Interaction Server. For all interaction
// types any attached data programmatical update applied after interaction release
// is not reflected in UI controls such as 'Case information'.
This is my code:
Genesyslab.Platform.Commons.Collections.KeyValueCollection keyValueCollectionUpDate = new Genesyslab.Platform.Commons.Collections.KeyValueCollection();
keyValueCollectionUpDate.Add("Business Result", "Platform: Business Result");
keyValueCollectionUpDate.Add("StrAttribute1", "AttachedData.Business Result"); RequestAttachUserData requestAttachUserData= RequestAttachUserData.Create("7012", GetConnectionID(ExtractedArtributes[1][0].Value.ToString()), keyValueCollectionUpDate); IMessage respondingEvent2=tserverProtocol.Request(requestAttachUserData);
Need to add call attts after the call is dropped
You can't update attached data when the call is dropped.
I do a workaround by using WDE itself to attach data when agent clicks 'mark done' in WDE custom command.
The way to attach data to voice calls after disconnect, is to send a UserEvent. This does require the AfterCallWork state to be enabled in your environment. You have already mentioned understanding how to insert Commands into the Command Chain. This example Execute function of a command can be inserted into the "BundleClose" Command Chain, prior to the "Close" Command.
This sample is in VB, apologies, but I guess you can easily convert to c#.
Public Function Execute(ByVal parameters As IDictionary(Of String, Object), ByVal progress As IProgressUpdater) As Boolean Implements IElementOfCommand.Execute
' To go to the main thread
If Application.Current.Dispatcher IsNot Nothing AndAlso Not Application.Current.Dispatcher.CheckAccess() Then
Dim result As Object = Application.Current.Dispatcher.Invoke(DispatcherPriority.Send, New ExecuteDelegate(AddressOf Execute), parameters, progress)
Return CBool(result)
Else
Dim interactionsBundle As IInteractionsBundle = Nothing
Dim interaction As IInteraction = Nothing
interactionsBundle = parameters("CommandParameter")
interaction = interactionsBundle.MainInteraction
Dim channel As Enterprise.Model.Channel.IClientChannel = interaction.EntrepriseInteractionCurrent.ActiveChannel 'agent.Channel
Dim protocol As IProtocol = channel.Protocol
Dim kvp As Platform.Commons.Collections.KeyValueCollection = New Platform.Commons.Collections.KeyValueCollection()
kvp.Add("keyname", "keyvalue")
Dim userevent As Platform.Voice.Protocols.TServer.CommonProperties = Platform.Voice.Protocols.TServer.CommonProperties.Create()
userevent.UserData = kvp
Dim connID As Platform.Voice.Protocols.ConnectionId = Nothing
Dim interactionVoice as IInteractionVoice = TryCast(interaction, IInteractionVoice)
If interactionVoice IsNot Nothing Then
userevent.UserEvent = Platform.Voice.Protocols.TServer.Events.EventUserEvent.MessageId
connID = New Platform.Voice.Protocols.ConnectionId(interactionVoice.TConnectionId)
Dim strDN As String = Nothing
'ensure the correct DN is passed when attaching reason codes, in case agent is logged into multiple DNs
Dim devices() As Enterprise.Model.Device.IDevice = interactionVoice.Device
Dim device As Enterprise.Core.DN = devices(0)
strDN = device.Name
userevent.ThisDN = strDN
userevent.ConnID = connID
Dim req = Platform.Voice.Protocols.TServer.Requests.Special.RequestSendEvent.Create()
req.UserEvent = userevent
'send request
protocol.Send(req)
End If
End If
End Function

How to add custom mailheader using cdo.message in Vb6

I have tried to use the following code to add custom mail header in VB6. But it didnt work.
Can anyone help me out?
Dim lobj_cdomsg As CDO.Message
Set lobj_cdomsg = New CDO.Message
'Add the Project Reference Miscrosoft CDO WINDOWS FOR 2000
lobj_cdomsg.Configuration.Fields(cdoSMTPServer) = "servername"
lobj_cdomsg.Configuration.Fields(cdoSMTPConnectionTimeout) = 30
lobj_cdomsg.Configuration.Fields(cdoSendUsingMethod) = 2
lobj_cdomsg.Configuration.Fields(cdoSMTPAuthenticate) = 1
lobj_cdomsg.Configuration.Fields(cdoSendUserName) = "username"
lobj_cdomsg.Configuration.Fields(cdoSendPassword) = "password"
lobj_cdomsg.Configuration.Fields(cdoSMTPServerPort) = "587"
lobj_cdomsg.Configuration.Fields("urn:schemas:mailheader:X-MC-Tags") = "CKSR001"
'lobj_cdomsg.Fields("urn:schemas:mailheader:X-MC-Tags") = "CKSR002"
lobj_cdomsg.Configuration.Fields.Update
lobj_cdomsg.To = "to user"
lobj_cdomsg.From = "from"
lobj_cdomsg.Subject = "FROM VB6 CODSYS"
lobj_cdomsg.TextBody = "New Mail"
lobj_cdomsg.TextBody = "New Mail"
lobj_cdomsg.Send
Set lobj_cdomsg = Nothing
You have to add your "urn:schemas:mailheader:X-..." header as a field of the Message object, not Message.Configuration.
Add the following two lines before sending the message: (and remove your non-working line)
lobj_cdomsg.Fields("urn:schemas:mailheader:X-MC-Tags") = "CKSR001"
lobj_cdomsg.Fields.Update
Then it should work.

WMI Scripting issues displaying multiple drive info

Please note that I am a newbie in WMI, have been researching this issue for most of the day, and even though there are hundres of posts, I am struglling to find any help on this specific problem.
Experiencing an issues using Win32_DiskDrive - Caption and also name functions:
When I execute the VB.script:
Try
Dim connection As New ConnectionOptions
connection.Username = userNameBox.Text
connection.Password = passwordBox.Text
connection.Authority = "ntlmdomain:ms1"
Dim scope As New ManagementScope( _
"\\ms1\root\CIMV2", connection)
scope.Connect()
Dim query As New ObjectQuery( _
"SELECT * FROM Win32_DiskDrive")
Dim searcher As New ManagementObjectSearcher(scope, query)
For Each queryObj As ManagementObject in searcher.Get()
Console.WriteLine("-----------------------------------")
Console.WriteLine("Win32_DiskDrive instance")
Console.WriteLine("-----------------------------------")
Console.WriteLine("Caption: {0}", queryObj("Caption"))
Next
it correctly lists the 5 harddrives that I have in the server i am querying.
But when I execute it in asp.net (vb) it lists only the 1 drive.
Dim query4 As New ObjectQuery("Select * from Win32_DiskDrive")
Dim searcher4 As New ManagementObjectSearcher(scope, query4)
For Each queryObj3 As ManagementObject In searcher4.Get()
'Availability
' text15.Text = queryObj3("Name")
text16.Text = queryObj3("Caption")
Next
My resuls are bountd to a textfield, formatted to wrap and multiline.
Regards
Louis van Rooyen
It seems you overrwrite text16.Text again and again, so the result in the end would be the information of the last device only.
Try concatenating the string instead:
' TODO: Use proper string formating instead of simpy string concatenating '
text16.Text = text16.Text & queryObj3("Caption")

Crystal Reports TestConnection Fails

I have a Crystal Reports app that I am loading through VS2010. I have the CR Runtime 13.0.2 loaded on my machine. When I run the app using debug, it works fine. (Great in fact.) But when I install the application that is built (even on the VERY same dev machine.) the TestConnection line comes back false, which indicates to me that it's not connecting properly to my database.
If I don't put this code in there, the app prompts for login credentials at THIS line:
Me.CrystalReportViewer1.ReportSource = reportDocument1
But the DB Name and Server Name are incorrect and grayed out, and anything that I put in UserName and PW doesn't work.
I've searched google and tried any number of "fixes" and NOTHING gets it to work.
I also used database expert to "update" my datasource, and ran a "verify database" from design mode and still the same thing happens.
Here is my code:
Private Function ConnectReport(sDatabaseFile As String, _serverName As String, ReportDocument1 As ReportDocument)
ReportDocument1.SetDatabaseLogon("sa", "sqlAdmin2008", _serverName, sDatabaseFile, True)
For x As Integer = 0 To ReportDocument1.DataSourceConnections.Count - 1
ReportDocument1.DataSourceConnections(x).SetConnection(_serverName, sDatabaseFile, "sa", "sqlAdmin2008")
Next
For Each cTable As Table In ReportDocument1.Database.Tables
If cTable.Name <> "Command" Then
SetTableConnectionInfo(cTable, sDatabaseFile, _serverName)
End If
Next
For Each obj As ReportObject In ReportDocument1.ReportDefinition.ReportObjects
If obj.Kind = ReportObjectKind.SubreportObject Then
Dim subReport As SubreportObject = CType(obj, SubreportObject)
Dim subReportDocument As ReportDocument = ReportDocument1.OpenSubreport(subReport.SubreportName)
ConnectReport(sDatabaseFile, _serverName, subReportDocument)
End If
Next
End Function
Private Function SetTableConnectionInfo(cTable As Table, sDatabaseFile As String, _serverName As String)
Dim logonInfo As TableLogOnInfo = cTable.LogOnInfo
Dim connInfo As ConnectionInfo = New ConnectionInfo()
connInfo.DatabaseName = sDatabaseFile
connInfo.ServerName = _serverName
connInfo.UserID = "sa"
connInfo.Password = "sqlAdmin2008"
'connInfo.Type = ConnectionInfoType.SQL
logonInfo.ConnectionInfo = connInfo
cTable.ApplyLogOnInfo(logonInfo)
If cTable.TestConnectivity = False Then
Throw New ApplicationException("Cannot connect Crystal Reports to Database.")
End If
cTable.Location = sDatabaseFile & "." & "dbo" & "." & cTable.Location
End Function
It would seem to me that you need to pass the table in as a reference like this.
Private Function SetTableConnectionInfo(ref cTable As Table, sDatabaseFile As String, _serverName As String)

Resources