![]() ngrok redirects requests from this URL to our localhost using its tunnelling service. Here we are interested in the Forwarding line – it contains the public URL. Run tunnelling for this port:įorwarding -> Connections ttl opn rt1 rt5 p50 p90 In terminal (on macOS or Linux) or in the command line (on Windows), open the ngrok directory.īy default, our Ktor project is configured to run the HTTP server on the port 8080 (you can check this in the resources/nf file). As your development environment is probably located behind NAT, the easiest way to get the URL is to use a tunneling service. When adding new endpoints to your application, make sure to verify incoming requests as we do later in this tutorial.īefore we register our chatbot in Space, we have to get a publicly available URL for it. An open and publicly-available port on your computer poses a severe security threat. Do not use it to host the chatbot on your computer on a regular basis. We strongly recommend that you use a tunneling service only for testing purposes during development. In the Gradle window, click Reload All Gradle Projects to make Gradle download the required dependencies.ĭone! Now, we have Space SDK in our project. Implementation("io.ktor:ktor-client-cio:$ktor_version") Implementation("io.ktor:ktor-client-core:$ktor_version") Implementation("org.jetbrains:space-sdk-jvm:$space_sdk_version") Implementation(":jackson-module-kotlin:$jackson_version") Implementation("ch.qos.logback:logback-classic:$logback_version") Implementation("io.ktor:ktor-server-netty-jvm:$ktor_version") Implementation("io.ktor:ktor-server-core-jvm:$ktor_version") Val isDevelopment: Boolean = ("development")ĪpplicationDefaultJvmArgs = listOf("=$isDevelopment") We'll use the CIO Ktor HTTP client but you can use any other web engine for the HTTP client. We'll need a client to send requests to Space. Ktor HTTP client: a generic Ktor app doesn't reference libraries for HTTP client. The snippets always reference the latest available version of the SDK.įasterXML/jackson: to work with JSON payloads. This will open a window with snippets for Gradle and Maven. On the right, in the list under Code, select Kotlin SDK and click Set up dependency. To get the instructions on how to reference the latest SDK, open API Playground in your Space instance ( Extensions | API Playground). Our chatbot requires the following libraries: That's it! Now, we have a blank Ktor project. We're not going to install any Ktor plugins, so, on the next page just click Create. ![]() Specify a project Name and a Website name, select Gradle Kotlin in Build System, and clear the Add sample code checkbox.Ĭlick Next. Start creating a new project with File | New | Project. An open and publicly-available port on your computer poses a serious security threat. Do not use it to host the chatbot on your computer on regular basis. We strongly recommend that you use a tunnelling service only for testing purposes during development. For our purposes, the free plan for ngrok or PageKyte is enough. To start working with the tunneling service, you should download a service client: ngrok client, PageKyte client. For example, you can use ngrok, PageKyte, or another tunnelling service for this purpose. It will let us run our chatbot locally and access it from Space via a public URL (we'll specify it as the chatbot's endpoint). Such a service exposes local servers to the public internet. As well as the Ktor framework, we'll get the SDK as a Gradle dependency. The SDK contains the HTTP API client that lets you easily authenticate in and communicate with Space by using multiple high-level classes. To ease the life of Space app developers, we provide Space SDK for Kotlin and. Of course, outside of this tutorial, you can create a Space bot using any web framework you like, e.g., Node.js, ASP.NET, and so on.Īs you might know from the Develop Applications topic, any application must communicate with Space using Space HTTP API. We'll get it as one of Gradle dependencies, so, no additional actions are required from your side. This is a framework that lets you easily create all types of connected applications, e.g., servers, clients, mobile, and browser-based apps. So, you can use any IDE of your choice, but this tutorial implies that you use IntelliJ IDEA.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |