Skip to main content
AI
  • Get started with AI

    • Red Hat AI

      Accelerate the development and deployment of enterprise AI solutions.

    • AI learning hub

      Explore learning materials and tools, organized by task.

    • AI interactive demos

      Click through scenarios with Red Hat AI, including training LLMs and more.

    • AI/ML learning paths

      Expand your Red Hat OpenShift AI knowledge using these learning resources.

    • AI quickstarts

      Focused AI use cases designed for fast deployment on Red Hat AI platforms.

    • No-cost AI training

      Foundational Red Hat AI training.

  • Featured resources

    • Red Hat OpenShift AI
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

Red Hat AI Factory with NVIDIA

Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.

Learn
  • Self-guided

    • Documentation

      Find answers, get step-by-step guidance, and learn how to use Red Hat products.

    • Learning paths

      Explore curated walkthroughs for common development tasks.

    • Guided learning

      Receive custom learning paths powered by our AI assistant.

    • See all learning
  • Hands-on

    • Developer Sandbox

      Spin up Red Hat's products and technologies without setup or configuration.

    • Interactive labs

      Learn by doing in these hands-on, browser-based experiences.

    • Interactive demos

      Click through product features in these guided tours.

  • Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics
  • Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
Build
  • Get started

    • Red Hat build of Podman Desktop

      A downloadable, local development hub to experiment with our products and builds.

    • Developer Sandbox

      Spin up Red Hat's products and technologies without setup or configuration.

  • Download products

    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products
  • Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset
  • References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
Community
  • Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions
  • Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github
  • Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

Join the Red Hat Developer program

Download Red Hat products and project builds, access support documentation, learning content, and more.

ConsoleDocsSupport Search
New For you

Recommended

We'll recommend resources you may like as you browse. Try these suggestions for now.

  • Product downloads
  • Cheat sheets
  • Red Hat Developer learning portal
  • Developer blog
  • E-books
  • Developer Sandbox
Log in

Get more with a Red Hat Developer account

  • Product downloads
  • Console access
  • Event registration
  • Training & trials
Explore more account benefitsLog in or register

A subscription may be required for some services.

Contact us

Sending a telegram with Apache Camel K and Visual Studio Code

September 30, 2019
Brian Fitzpatrick
Related topics:
Developer toolsIDEs

    When I was introduced to Apache Camel K a few months ago, I was amazed at how quickly developers could write and deploy an Apache Camel-based integration on Kubernetes. We immediately started work on creating Microsoft Visual Studio (VS) Code-based tools to make things even easier.

    What is Camel K? It’s a lightweight integration framework built from Apache Camel and designed for a serverless/microsystem world that runs natively on Kubernetes. It lets developers write integrations in their favorite Camel DSL and quickly deploy them on Kubernetes or Red Hat OpenShift. You can even write your integrations in lightweight languages like Groovy or JavaScript.

    We already built language support in VS Code for Apache Camel using the Language Server Protocol (LSP), offering auto-completion for Camel component URIs in both XML and Java. More recently, we began adding the same support for Groovy, JavaScript, YAML, and Kotlin. (See the Apache Camel LSP client project for details.)

    Now, with our new Tooling for Apache Camel K by Red Hat extension, we add support for Camel K in your IDE. To illustrate the tools in action, let’s start with a simple user story inspired by an article that Nicola Ferraro wrote a few years ago (Creating a Telegram Bot in 5 minutes with Apache Camel).

    • As a developer, I want to send myself a telegram notice any time somebody mentions the hashtag #camelkrocks so that I can better engage with our social media community.

    To get started, let’s assume that you have the following:

    • Telegram account and access to the Telegram messaging client or access via https://web.telegram.org/.
    • Apache Camel K running in an accessible Kubernetes instance, with the Kubernetes and Camel K command line tools installed locally.
    • Microsoft Visual Studio Code running locally with the Tooling for Apache Camel K by Red Hat extension installed.

    Before you create the Camel K side of the Telegram bot, you have to create your bot on Telegram. Nicola did a great job detailing those steps in his article; see the section on creating the Telegram bot there and give your bot a unique name, like camelk-hashtag-telegram-bot. Be sure to note the authorization token given by the @BotFather.

    Now in VS Code, create a new workspace with an empty directory called hashtagbot. In the hashtagbot directory, create a file named hashtagbot.groovy and copy this text into the file:

    from("telegram:bots/replace-me-with-your-telegram-token")
        .choice()
            .when()
                .simple('${in.body} != null')
                .to("direct:response1")
    
    from("direct:response1")
        .log('Incoming message from Telegram is ${in.body}')
        .setBody()
            .simple('You said \"${in.body}\"?')
            .to("telegram:bots/replace-me-with-your-telegram-token")

    Note: Remember to replace “replace-me-with-your-telegram-token” with your Telegram authorization token given by the @BotFather.

    After you save your file, right-click it and select Start Apache Camel K Integration from the pop-up menu. A drop-down appears in the command palette with a few choices. Select Dev Mode - Apache Camel K Integration in Dev Mode.

    As your integration starts to run, watch the Apache Camel K output channel that appears:

    In your Telegram app, find your bot (use the name you specified when you created the bot in @BotFather) and start a new conversation. Everything you type in Telegram should be repeated with “You said “<whatyoutyped>?” For example:

    Next, update your route to check whether a given string has our hashtag #camelkrocks in it and respond accordingly.

    Change the second route in your hashtagbot.groovy file as follows:

    from("direct:response1")
        .log('Incoming message from Telegram is ${in.body}')
            .choice()
            .when(simple('${bodyAs(java.lang.String)} contains "#camelkrocks"'))
            .setBody(simple('Did somebody say #camelrocks? Of course it does!'))
            .to("telegram:bots/replace-me-with-your-telegram-token")
                    .end()

    Once you save your route, it updates the deployed integration and you can try it out. For example:

    Though this is a very simple example, you could use the approach as a basis to do things like routing messages to a database or to an email address for follow-up later.

    We also have different deployment options that can save you from having to include your telegram token in the body of your route.

    One way is to use the Apache Camel K “property” option.

    1. In the hashtagbot.groovy file, edit the route by replacing your token with {{telegram-token}}.
    2. When you start the integration, deploy the route by selecting the Property - Apache Camel K Integration with Property option in the drop-down menu.
    3. Specify a property with the name telegram-token and the value as your telegram authentication token. The runtime will replace {{telegram-token}} with your token value.

    Another way is to use the Apache Camel K ConfigMap or Secret method.  With this method, your token value is secured in the Kubernetes system.

    For example, to use the Secret method:

    1. Create a new application.properties file and save it to your hashtagbot folder.
    2. In the application.properties file, add the following line (replace the value with your actual token):
      telegram-token=replace-me-with-your-telegram-token
    3. Right-click on the application.properties file and then select Create Kubernetes Secret from File.
    4. Name the new secret telegram-secret.
    5. In the hashtagbot.groovy file, edit the route by replacing your token with {{telegram-token}}.
    6. When you start the integration, deploy the route by selecting the Secret - Apache Camel K Integration with Kubernetes Secret option in the drop-down menu.
    7. In the drop-down list that appears, specify the telegram-secret that you created. The Camel K runtime will replace {{telegram-token}} with your token value.

    To learn more, check out the latest on Apache Camel K and see the Tooling for Apache Camel K by Red Hat extension for Microsoft VS Code.

    Happy coding!

    Last updated: July 1, 2020

    Recent Posts

    • A day in the life of an NVIDIA H100 on Red Hat OpenShift 5

    • Migrate BuildConfigs to builds for Red Hat OpenShift with one plug-in install

    • Run Red Hat Enterprise Linux CoreOS on NVIDIA BlueField DPUs

    • Agent harness engineering: Separating model capabilities from enforcement

    • What's new for developers in Red Hat Enterprise Linux 10.3 and 9.9

    Red Hat Developers logo

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    Red Hat Developer

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility
    Ask AI