我在内部 Web 服务器上部署了一个机器人,并且我有一个客户端应用程序(不是 Web 客户端)非常愉快地使用 REST API 调用与它交谈。
我不知道如果您使用机器人的 Azure URL(而不是 Bot Framework 中的 URL),同样的概念是否会起作用,但它可能值得一试。如果 Bot Emulator 可以与 Azure 对话,那么任何 REST API 都应该可以工作。
您需要一个合适的 JSON 字符串作为消息正文发送。我复制了您在 Bot Emulator 中看到的 JSON,并将其用作基础。
Dim client As RestClient = New RestClient(_localAddress) 'Address of the Bot
Dim request As RestRequest = New RestRequest("api/messages", Method.POST)
Dim byteArray = System.Text.Encoding.ASCII.GetBytes(_appID & ":" & _appsecret) ' Appropriate application secret and ID
request.AddHeader("Authorization", "Basic " & Convert.ToBase64String(byteArray))
'messageDetails is my message class dervived from the Json from the Bot Emulator
messageDetails.text = messageToRelay
request.AddJsonBody(messageDetails)
' response is then deserialised to a suitable BotReply class, again based on the Json you can see in Bot Emulator
Dim response = client.Execute(request)
您需要管理相关类中的一些变量以维护消息链,但是通过检查您可以在 Bot Emulator 中看到的 Json 响应,您应该能够将其挑选出来
我很欣赏答案不是基于 CURL,但希望它可能会有所帮助,您可以根据需要进行调整