SwaggerClient - the Ruby gem for the Bot Connector - Direct Line API - V1.0
Direct Line =========== The Direct Line API is a simple REST API for connecting directly to a single bot. This API is intended for developers writing their own client applications, web chat controls, or mobile apps that will talk to their bot. Credentials for the Direct Line API may be obtained from the Bot Framework developer portal, and will only allow the caller to connect to the bot for which they were generated. If you are writing a server-to-server application, the Direct Line secret may be used directly against the API. If instead you are writing an application where a client connects directly (and possibly insecurely) to the Direct Line API, you may exchange the secret for a token that will work only for a single conversation and only for a limited amount of time. Tokens expire by default after 30 minutes although they may be renewed up until their expiration. The secret or token (depending on the authorization model) are supplied as basic auth with the "BotConnector" scheme and no further encoding. Example auth header: -- connect to directline.botframework.com -- GET /api/tokens Authorization: BotConnector RCurR_XV9ZA.cwA.BKA.iaJrC8xpy8qbOF5xnR2vtCX7CZj0LdjAPGfiCpg4Fv0 Don't include the Ocp-Apim-Subscription-Key header. The contents of this header are your bot's secret key. The bot's secret key is not necessary when using the Direct Line API. Each conversation on the Direct Line channel must be explicitly started using a POST to the https://directline.botframework.com/api/conversations endpoint. If the call was authorized with a token, the conversation ID is the conversation ID in the scoped token. If a secret was used to start the conversation, the conversation will be started with a new, random ID. The client may send messages to the bot by calling POST on https://directline.botframework.com/api/conversations/{conversationId}/messages. The client may retrieve messages sent by the bot by calling GET on https://directline.botframework.com/api/conversations/{conversationId}/messages. The JSON structure returned contains a watermark that can be sent on subsequent requests to skip old messages. The Direct Line API does not store messages indefinitely. Your client application must pick them up quickly before they are deleted. # Client libraries for the Direct Line API * Direct Line Nuget package * Generate your own from the Direct Line Swagger file
This SDK is automatically generated by the Swagger Codegen project:
- API version: v1
- Package version: 1.0.0
- Build date: 2016-08-10T09:20:22.973Z
- Build package: class io.swagger.codegen.languages.RubyClientCodegen For more information, please visit https://botframework.com
To build the Ruby code into a gem:
gem build swagger_client.gemspec
Then either install the gem locally:
gem install ./swagger_client-1.0.0.gem
(for development, run gem install --dev ./swagger_client-1.0.0.gem
to install the development dependencies)
or publish the gem to a gem hosting service, e.g. RubyGems.
Finally add this to the Gemfile:
gem 'swagger_client', '~> 1.0.0'
If the Ruby gem is hosted at a git repository: https://github.com/YOUR_GIT_USERNAME/YOUR_GIT_REPO, then add the following in the Gemfile:
gem 'swagger_client', :git => 'https://github.com/YOUR_GIT_USERNAME/YOUR_GIT_REPO.git'
Include the Ruby code directly using -I
as follows:
ruby -Ilib script.rb
Please follow the installation procedure and then run the following code:
# Load the gem
require 'swagger_client'
api_instance = SwaggerClient::ConversationsApi.new
conversation_id = "conversation_id_example" # String | Conversation ID
opts = {
watermark: "watermark_example" # String | (Optional) only returns messages newer than this watermark
}
begin
#Get messages in this conversation. This method is paged with the 'watermark' parameter.
result = api_instance.conversations_get_messages(conversation_id, opts)
p result
rescue SwaggerClient::ApiError => e
puts "Exception when calling ConversationsApi->conversations_get_messages: #{e}"
end
All URIs are relative to https://directline.botframework.com
Class | Method | HTTP request | Description |
---|---|---|---|
SwaggerClient::ConversationsApi | conversations_get_messages | GET /api/conversations/{conversationId}/messages | Get messages in this conversation. This method is paged with the 'watermark' parameter. |
SwaggerClient::ConversationsApi | conversations_new_conversation | POST /api/conversations | Start a new conversation |
SwaggerClient::ConversationsApi | conversations_post_message | POST /api/conversations/{conversationId}/messages | Send a message |
SwaggerClient::ConversationsApi | conversations_upload | POST /api/conversations/{conversationId}/upload | Upload file(s) and send as attachment(s) |
SwaggerClient::TokensApi | tokens_generate_token_for_new_conversation | POST /api/tokens/conversation | Generate a token for a new conversation |
SwaggerClient::TokensApi | tokens_renew_token | GET /api/tokens/{conversationId}/renew | Renew a token for a conversation |
- SwaggerClient::Attachment
- SwaggerClient::Conversation
- SwaggerClient::Error
- SwaggerClient::ErrorMessage
- SwaggerClient::Message
- SwaggerClient::MessageSet
- SwaggerClient::Object
- Type: HTTP basic authentication