Skip to content

Latest commit

 

History

History

spring-messaging-auto-response

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Telnyx Java Auto Response

Telnyx

Sample application demonstrating Java SDK Basics

About

This application demonstrates:

  • Receiving webhooks from Telnyx
  • Parsing contents from inbound message
  • Building an outbound message request
  • Sending outbound message based on particular keyword

Pre-Reqs

You will need to set up:

Usage

The following environmental variables need to be set

Variable Description
TELNYX_API_KEY Your Telnyx API Key

.env file

This app uses the excellent dotenv-java package to manage environment variables.

Make a copy of .env.sample and save as .env and update the variables to match your creds.

TELNYX_API_KEY="KEYLoremIpsum"

Callback URLs For Telnyx Applications

Callback Type URL
Inbound Message Callback {ngrok-url}/messaging/inbound
Outbound Message Status Callback {ngrok-url}/messaging/outbound built at run time

Install

Run the following commands to get started

$ git clone https://github.com/d-telnyx/demo-java-telnyx.git
$ cd spring-messaging-auto-response
$ mvn clean install

Ngrok

This application is served on the port defined in the runtime environment (or in the .env file). Be sure to launch ngrok for that port

./ngrok http 8000

Terminal should look something like

ngrok by @inconshreveable                                                                                                                               (Ctrl+C to quit)

Session Status                online
Account                       Little Bobby Tables (Plan: Free)
Version                       2.3.35
Region                        United States (us)
Web Interface                 http://127.0.0.1:4040
Forwarding                    http://your-url.ngrok.io -> http://localhost:8000
Forwarding                    https://your-url.ngrok.io -> http://localhost:8000

Connections                   ttl     opn     rt1     rt5     p50     p90
                              0       0       0.00    0.00    0.00    0.00

At this point you can point your application to generated ngrok URL + path (Example: http://{your-url}.ngrok.io/Callbacks/Voice/Inbound).

Run

Open your IDE and run the application to launch the spring server

Then text your Telnyx number from your mobile to get different responses!

demo

Development

Application was generated from SpringGenerators, see the Help.md for more information.

⚠️ FOR SPRING USERS

The SDK is built using openapi-generator, in order to use the deserializers, you need to include jackson-databind-nullable (see Stack Overflow)

Add to pom.xml

<dependency>
  <groupId>org.openapitools</groupId>
  <artifactId>jackson-databind-nullable</artifactId>
  <version>0.2.1</version>
</dependency>

Add to objectMapper

@Autowired
void configureObjectMapper(final ObjectMapper mapper) {
    mapper.registerModule(new JsonNullableModule());
}