Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Global rule:
* @Bandwidth-Samples/band-swi
* @Bandwidth-Samples/band-swi @Bandwidth-Samples/band-devx
11 changes: 0 additions & 11 deletions .github/actions/maven-test/Dockerfile

This file was deleted.

6 changes: 0 additions & 6 deletions .github/actions/maven-test/action.yml

This file was deleted.

3 changes: 0 additions & 3 deletions .github/actions/maven-test/entrypoint.sh

This file was deleted.

19 changes: 19 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: 2

updates:
- package-ecosystem: maven
directory: /
schedule:
interval: monthly
open-pull-requests-limit: 5
ignore:
- dependency-name: "com.bandwidth.sdk:bandwidth-sdk"
update-types:
- version-update:semver-minor
- version-update:semver-patch
groups:
dependencies:
patterns:
- "*"
exclude-patterns:
- "com.bandwidth.sdk:bandwidth-sdk"
16 changes: 0 additions & 16 deletions .github/workflows/on-pull-request.yaml

This file was deleted.

15 changes: 15 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Test

on:
pull_request:
branches:
- main
schedule:
- cron: "0 9 * * 1"

jobs:
contract-test:
name: Contract Test
uses: Bandwidth-Samples/sample-app-tooling/.github/workflows/java.yml@main
with:
sample: messaging-auto-respond
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Bandwidth Samples
Copyright (c) 2026 Bandwidth Samples

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Auto-Respond to SMS
# Messaging Auto Respond

<a href="http://dev.bandwidth.com/docs/messaging/quickStart">
<a href="https://dev.bandwidth.com/docs/messaging/quickStart">
<img src="./icon-messaging.svg" title="Messaging Quick Start Guide" alt="Messaging Quick Start Guide"/>
</a>

Expand All @@ -11,15 +11,17 @@
* [Running the Application](#running-the-application)
* [Environmental Variables](#environmental-variables)
* [Callback URLs](#callback-urls)
* [Ngrok](#ngrok)
* [Ngrok](#ngrok)

# Description

This app automatically responds to texts sent to the associated Bandwidth number. Any texts sent to the `BW_NUMBER` will be auto-responded to using the auto response map. Valid words are: `STOP`, `QUIT`, `HELP`, and `INFO`.
This sample app automatically replies to texts sent to your Bandwidth number. The reply depends on the text received: `STOP`, `QUIT`, `HELP` and `INFO` each get their own reply, and anything else gets a prompt to reply `HELP`. Keywords are matched against the whole message and are not case sensitive.

To use this app, you must check the "Use multiple callback URLs" box on the application page in Dashboard. Then in Dashboard, set the INBOUND CALLBACK to `/callbacks/inbound/messaging` and the STATUS CALLBACK to `/callbacks/outbound/messaging/status`. The same can be accomplished via the Dashboard API by setting InboundCallbackUrl and OutboundCallbackUrl respectively.
The `STOP` and `QUIT` replies are for demonstration only. This app doesn't keep track of opt-outs, so it will keep replying to a number that has sent `STOP`.

Inbound callbacks are sent notifying you of a received message on a Bandwidth number, this app sends a custom response to those messages based on their content. Outbound callbacks are status updates for messages sent from a Bandwidth number, this app has a dedicated response for each type of status update.
In order to use the correct endpoints, you must check the "Use multiple callback URLs" box on the application page in Dashboard. Then in Dashboard, set the INBOUND CALLBACK to `/callbacks/inbound/messaging` and the STATUS CALLBACK to `/callbacks/outbound/messaging/status`. The same can be accomplished via the Dashboard API by setting `InboundCallbackUrl` and `OutboundCallbackUrl` respectively.

Inbound callbacks are sent notifying you of a received message on a Bandwidth number. This app prints the phone numbers involved and the text received, then sends the reply. Outbound callbacks are status updates for messages sent from a Bandwidth number, this app has a dedicated response for each type of status update.

# Pre-Requisites

Expand All @@ -31,10 +33,10 @@ For more information about API credentials see our [Account Credentials](https:/

# Running the Application

To install the required packages for this app, run the command:
To install the required packages and build the app, run the command:

```sh
mvn clean install
mvn package
```

Use the following command to run the application:
Expand All @@ -49,8 +51,8 @@ The sample app uses the below environmental variables.

```sh
BW_ACCOUNT_ID # Your Bandwidth Account Id
BW_USERNAME # Your Bandwidth API Username
BW_PASSWORD # Your Bandwidth API Password
BW_CLIENT_ID # Your Bandwidth API OAuth Client Id
BW_CLIENT_SECRET # Your Bandwidth API OAuth Client Secret
BW_NUMBER # The Bandwidth phone number involved with this application
BW_MESSAGING_APPLICATION_ID # Your Messaging Application Id created in the dashboard
LOCAL_PORT # The port number you wish to run the sample on
Expand All @@ -66,13 +68,11 @@ Below are the callback paths:

## Ngrok

A simple way to set up a local callback URL for testing is to use the free tool [ngrok](https://ngrok.com/).
A simple way to set up a local callback URL for testing is to use the free tool [ngrok](https://ngrok.com/).
After you have downloaded and installed `ngrok` run the following command to open a public tunnel to your port (`$LOCAL_PORT`)

```cmd
```sh
ngrok http $LOCAL_PORT
```

You can view your public URL at `http://127.0.0.1:4040` after ngrok is running. You can also view the status of the tunnel and requests/responses here.

Once your public ngrok url has been created, you can use it as the `BASE_CALLBACK_URL` environmental variable and set it in the messaging application created in the [pre-requisites](#pre-requisites) section.
You can view your public URL at `http://127.0.0.1:4040` after ngrok is running. You can also view the status of the tunnel and requests/responses here. Once your public ngrok url has been created, use it as the base of the callback URLs in the messaging application created in the [Pre-Requisites](#pre-requisites) section.
1 change: 0 additions & 1 deletion application.properties

This file was deleted.

4 changes: 3 additions & 1 deletion icon-messaging.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 16 additions & 31 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,51 +11,36 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>11</java.version>
<spring.version>2.2.6.RELEASE</spring.version>
<java.version>21</java.version>
<spring.version>4.1.2</spring.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>

<!-- https://mvnrepository.com/artifact/com.bandwidth.sdk/bandwidth-sdk -->
<dependency>
<groupId>com.bandwidth.sdk</groupId>
<artifactId>bandwidth-sdk</artifactId>
<version>9.1.2</version>
</dependency>

<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.8.0</version>
</dependency>

<dependency>
<groupId>javax.activation</groupId>
<artifactId>javax.activation-api</artifactId>
<version>1.2.0</version>
<version>18.3.1</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -68,7 +53,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<version>3.16.0</version>
<configuration>
<!-- or whatever version you use -->
<source>${java.version}</source>
Expand Down
16 changes: 13 additions & 3 deletions src/main/java/com/bandwidth/Main.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.bandwidth;


import java.util.Collections;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
Expand All @@ -14,9 +15,18 @@ public class Main {
static Logger logger = LoggerFactory.getLogger(Main.class);

public static void main(String[] args) {
SpringApplication.run(Main.class, args);
String port = System.getenv("LOCAL_PORT");
if (System.getenv("BW_ACCOUNT_ID") == null || System.getenv("BW_CLIENT_ID") == null
|| System.getenv("BW_CLIENT_SECRET") == null || System.getenv("BW_MESSAGING_APPLICATION_ID") == null
|| System.getenv("BW_NUMBER") == null || port == null || !port.matches("\\d+")) {
System.err.println("Please set the environmental variables defined in the README");
System.exit(1);
}

SpringApplication application = new SpringApplication(Main.class);
application.setDefaultProperties(Collections.singletonMap("server.port", port));
application.run(args);
logger.info("Server has started...");
}


}
Loading
Loading