

- Chatbot app how to#
- Chatbot app install#
- Chatbot app verification#
- Chatbot app code#
- Chatbot app download#
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 -> Forwarding -> 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 tunnelling service. Minimize the time the service is running: Run the service only when you need it ( for example, when you are going to test the bot in Space).īefore we register our chatbot in Space, we have to get its publicly available URL.
Chatbot app verification#
In our case, we add verification when creating a Space client. Run the tunnelling service only after you provide verification of incoming requests for all accessible endpoints. Here are some basic considerations on using the tunnelling service:
Chatbot app download#
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:81262-beta" a newer version may be already available we use version 81262, but when you read this tutorial Implementation ':jackson-module-kotlin:2.13.0' TestImplementation ":kotlin-test:$kotlin_version" TestImplementation "io.ktor:ktor-server-tests:$ktor_version" Implementation "ch.qos.logback:logback-classic:$logback_version" Implementation "io.ktor:ktor-server-netty:$ktor_version" Implementation "io.ktor:ktor-server-core:$ktor_version" 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. This will open a window with instructions for Gradle and Maven.įasterXML/jackson: to work with JSON payloads. On the right, in the list under Code, select Kotlin SDK and click Set up dependency.
Chatbot app how to#
To get the instructions on how to reference the latest SDK, open API Playground, then select any endpoint the left. Our chatbot requires the following libraries: That's it! Now, we have a blank Ktor project.

Chatbot app install#
We're not going to install any Ktor plugins, so, on the next page just click Finish.
Chatbot app code#
Specify a project Name and a Website name, select Gradle Groovy 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. Node.js, ASP.NET, and so on).Īs you might know from the Applications topic, any application must communicate with Space using Space HTTP API. Of course, outside of this tutorial, you can create a Space bot using any web framework you like (e.g. 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, of course, this tutorial implies that you use Intellij IDEA.
