This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-kamelets-examples.git
The following commit(s) were added to refs/heads/main by this push: new a189ed1 Added Slack source Kamelet example through camel-jbang a189ed1 is described below commit a189ed1c334405b15f72a1da442b324c5d85489b Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Fri Mar 25 07:46:25 2022 +0100 Added Slack source Kamelet example through camel-jbang --- jbang/slack-source/README.md | 122 ++++++++++++++++++++++++ jbang/slack-source/slack-integration.properties | 2 + jbang/slack-source/slack-source.yaml | 28 ++++++ 3 files changed, 152 insertions(+) diff --git a/jbang/slack-source/README.md b/jbang/slack-source/README.md new file mode 100644 index 0000000..db965be --- /dev/null +++ b/jbang/slack-source/README.md @@ -0,0 +1,122 @@ +== Slack Source Example + +In this sample you'll use the Slack Source Kamelet with Camel-Jbang + +=== Install JBang + +First install JBang according to https://www.jbang.dev + +When JBang is installed then you should be able to run from a shell: + +[source,sh] +---- +$ jbang --version +---- + +This will output the version of JBang. + +To run this example you can either install Camel on JBang via: + +[source,sh] +---- +$ jbang app install camel@apache/camel +---- + +Which allows to run CamelJBang with `camel` as shown below. + +=== Setup the Slack Bot App + +1. Go to https://api.slack.com/apps and create an app +2. Set the following permissions to this app, in particular in relation to Bot Token +- channels:history +- groups:history +- im:history +- mpim:history +- channels:read +- groups:read +- im:read +- mpim:read +3. Enable incoming webhook for this Bot App +4. Copy the User OAuth Token +5. Open the slack-integration.properties file and paste the token as token property +6. Set the correct channel name + +=== How to run + +Then you can run this example using: + +[source,sh] +---- +$ camel run --properties=slack-integration.properties slack-source.yaml +---- + +Or run with JBang using the longer command line (without installing camel as app in JBang): + +[source,sh] +---- +$ jbang camel@apache/camel run --properties=slack-integration.properties slack-source.yaml +---- + +You should see + +``` +Starting CamelJBang +2022-03-10 14:44:36.588 INFO 10188 --- [ main] e.camel.impl.engine.AbstractCamelContext : Detected: camel-debug JAR (enabling Camel Debugging) +2022-03-10 14:44:36.746 INFO 10188 --- [ main] org.apache.camel.main.BaseMainSupport : Auto-configuration summary +2022-03-10 14:44:36.746 INFO 10188 --- [ main] org.apache.camel.main.BaseMainSupport : camel.component.properties.location=file:///home/oscerd/workspace/miscellanea/kamelet-samples/camel-jbang/slack-source/slack-integration.properties, +2022-03-10 14:44:36.747 INFO 10188 --- [ main] org.apache.camel.main.BaseMainSupport : camel.main.name=CamelJBang +2022-03-10 14:44:36.747 INFO 10188 --- [ main] org.apache.camel.main.BaseMainSupport : camel.main.shutdownTimeout=5 +2022-03-10 14:44:36.747 INFO 10188 --- [ main] org.apache.camel.main.BaseMainSupport : camel.main.routesReloadEnabled=false +2022-03-10 14:44:36.747 INFO 10188 --- [ main] org.apache.camel.main.BaseMainSupport : camel.main.sourceLocationEnabled=true +2022-03-10 14:44:36.747 INFO 10188 --- [ main] org.apache.camel.main.BaseMainSupport : camel.main.tracing=false +2022-03-10 14:44:36.747 INFO 10188 --- [ main] org.apache.camel.main.BaseMainSupport : camel.main.routesIncludePattern=file:slack-source.yaml +2022-03-10 14:44:36.747 INFO 10188 --- [ main] org.apache.camel.main.BaseMainSupport : camel.component.kamelet.location=classpath:/kamelets,github:apache:camel-kamelets/kamelets +2022-03-10 14:44:36.840 INFO 10188 --- [ main] e.camel.management.JmxManagementStrategy : JMX is enabled +2022-03-10 14:44:37.430 INFO 10188 --- [ main] org.apache.camel.main.DownloaderHelper : Downloaded dependency: org.apache.camel:camel-gson:3.15.0 took: 500ms +2022-03-10 14:44:37.535 INFO 10188 --- [ main] org.apache.camel.main.DownloaderHelper : Downloaded dependency: org.apache.camel:camel-slack:3.15.0 took: 105ms +2022-03-10 14:44:38.853 INFO 10188 --- [ main] e.camel.impl.engine.AbstractCamelContext : Routes startup (total:3 started:3) +2022-03-10 14:44:38.853 INFO 10188 --- [ main] e.camel.impl.engine.AbstractCamelContext : Started route1 (kamelet://slack-source) +2022-03-10 14:44:38.853 INFO 10188 --- [ main] e.camel.impl.engine.AbstractCamelContext : Started slack-source-1 (slack://general) +2022-03-10 14:44:38.853 INFO 10188 --- [ main] e.camel.impl.engine.AbstractCamelContext : Started log-sink-2 (kamelet://source) +2022-03-10 14:44:38.854 INFO 10188 --- [ main] e.camel.impl.engine.AbstractCamelContext : Apache Camel 3.15.0 (CamelJBang) started in 2s152ms (build:123ms init:804ms start:1s225ms) +2022-03-10 14:44:38.854 INFO 10188 --- [ main] ache.camel.impl.debugger.BacklogDebugger : Enabling debugger +2022-03-10 14:44:40.105 INFO 10188 --- [slack://general] info : Exchange[ExchangePattern: InOnly, Headers: {Content-Type=application/json}, BodyType: byte[], Body: {"type":"message","team":"xxxx","user":"yyyy","text":"hello","blocks":[{"type":"rich_text","elements":[{"type":"rich_text_section","elements":[{"type":"text","text":"hello"}]}],"blockId":"XAE5"}],"ts":"1646919166.690039","is_intro":false,"is_starred":false,"wibblr":false,"displayAsBot":fals [...] +^C2022-03-10 14:44:47.276 INFO 10188 --- [ main] e.camel.impl.engine.AbstractCamelContext : Apache Camel 3.15.0 (CamelJBang) shutting down (timeout:5s) +2022-03-10 14:44:47.285 INFO 10188 --- [ main] e.camel.impl.engine.AbstractCamelContext : Routes stopped (total:3 stopped:3) +2022-03-10 14:44:47.285 INFO 10188 --- [ main] e.camel.impl.engine.AbstractCamelContext : Stopped log-sink-2 (kamelet://source) +2022-03-10 14:44:47.285 INFO 10188 --- [ main] e.camel.impl.engine.AbstractCamelContext : Stopped slack-source-1 (slack://general) +2022-03-10 14:44:47.285 INFO 10188 --- [ main] e.camel.impl.engine.AbstractCamelContext : Stopped route1 (kamelet://slack-source) +2022-03-10 14:44:47.286 INFO 10188 --- [ main] ache.camel.impl.debugger.BacklogDebugger : Disabling debugger +2022-03-10 14:44:47.288 INFO 10188 --- [ main] e.camel.impl.engine.AbstractCamelContext : Apache Camel 3.15.0 (CamelJBang) shutdown in 12ms (uptime:9s659ms) +``` + +=== Run directly from github + +The example can also be run directly by referring to the github URL as shown: + +[source,sh] +---- +$ jbang camel@apache/camel run https://github.com/apache/camel-kamelets-examples/tree/main/jbang/slack-source +---- + +=== Developer Web Console + +You can enable the developer console via `--console` flag as show: + +[source,sh] +---- +$ camel run --properties=slack-integration.properties slack-source.yaml --console +---- + +Then you can browse: http://localhost:8080/q/dev to introspect the running Camel applicaton. + + +=== Help and contributions + +If you hit any problem using Camel or have some feedback, then please +https://camel.apache.org/community/support/[let us know]. + +We also love contributors, so +https://camel.apache.org/community/contributing/[get involved] :-) + +The Camel riders! diff --git a/jbang/slack-source/slack-integration.properties b/jbang/slack-source/slack-integration.properties new file mode 100644 index 0000000..7fc5600 --- /dev/null +++ b/jbang/slack-source/slack-integration.properties @@ -0,0 +1,2 @@ +token=<token> +channel=general diff --git a/jbang/slack-source/slack-source.yaml b/jbang/slack-source/slack-source.yaml new file mode 100644 index 0000000..0e79d22 --- /dev/null +++ b/jbang/slack-source/slack-source.yaml @@ -0,0 +1,28 @@ +## --------------------------------------------------------------------------- +## Licensed to the Apache Software Foundation (ASF) under one or more +## contributor license agreements. See the NOTICE file distributed with +## this work for additional information regarding copyright ownership. +## The ASF licenses this file to You under the Apache License, Version 2.0 +## (the "License"); you may not use this file except in compliance with +## the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## --------------------------------------------------------------------------- +- route: + from: + uri: "kamelet:slack-source" + parameters: + channel: "{{channel}}" + token: "{{token}}" + steps: + - to: + uri: "kamelet:log-sink" + parameters: + showStreams: true + showHeaders: true