Skip to content
Open
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/workflows/samples-compilation.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Snippets Compilation
name: Examples Compilation

on: [push]

Expand Down
1 change: 1 addition & 0 deletions examples/compile.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/sh

(cd snippets && ./compile.sh) || exit 1
(cd webhooks && ./compile.sh) || exit 1
19 changes: 19 additions & 0 deletions examples/webhooks/.mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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.
wrapperVersion=3.3.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
79 changes: 79 additions & 0 deletions examples/webhooks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Backend application built using Sinch Java SDK to handle incoming webhooks

This directory contains a server application based onto [Sinch SDK java](https://github.com/sinch/sinch-sdk-java)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

English: don't use onto but on:

Suggested change
This directory contains a server application based onto [Sinch SDK java](https://github.com/sinch/sinch-sdk-java)
This directory contains a server application based on the [Sinch SDK java](https://github.com/sinch/sinch-sdk-java)

Onto implies movement toward a surface or position, this is not the case here


## Requirements

- JDK 21 or later (Sinch SDK Java is requiring java 8 only but client application can use latest available version)
- [Maven](https://maven.apache.org/)
- [SpringBoot](https://spring.io/projects/spring-boot)
- [Sinch account](https://dashboard.sinch.com)
- [ngrok](https://ngrok.com/docs)

## Configuration

### Configure application settings

com.mycompany.app.Application settings are using the `SpringBoot` configuration file: [`application.yaml`](src/main/resources/application.yaml) file and enable to configure:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this section. Is it an application package?


#### Sinch credentials
Located in `credentials` section (*you can find all of the credentials you need on your [Sinch dashboard](https://dashboard.sinch.com)*):
- `project-id`: YOUR_project_id
- `key-id`: YOUR_access_key_id
- `key-secret`: YOUR_access_key_secret
Comment on lines +21 to +23
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For most of the use cases, they are not needed


#### Server port
<em>Default: 8090</em>

Located in `server` section:
- port: The port to be used to listen to incoming requests. <em>Default: 8090</em>

## Usage

### Start server
1. Edit configuration file

See above for Configuration paragraph

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add reference link “See Configuration


2. Start server locally.

Compile and run the application as server locally.
```bash
./mvnw clean spring-boot:run
```
### EndPoints
When server is online, declared controllers will respond to following endpoints

| Service | Endpoint |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|
| [Conversation](https://developers.sinch.com/docs/conversation/callbacks) | /ConversationEvent |
| [Numbers](https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Numbers-Callbacks/#tag/Numbers-Callbacks/operation/ImportedNumberService_EventsCallback) | /NumbersEvent |
| [SMS](https://developers.sinch.com/docs/sms/api-reference/sms/tag/Webhooks/#tag/Webhooks/section/Callbacks) | /SmsEvent |
| [Verification](https://developers.sinch.com/docs/verification/api-reference/verification/tag/Verification-callbacks/) | /VerificationEvent |
| [Voice](https://developers.sinch.com/docs/voice/api-reference/voice/tag/Callbacks/) | /VoiceEvent |

## Use ngrok to forward request to local server

Forwarding request to same `8090` port used above:

*Note: The `8090` value is coming from default config and can be changed (see [Server port](#Server port) configuration section)*

```bash
ngrok http 8090
```

ngrok output will contains output like:
```
ngrok (Ctrl+C to quit)

...
Forwarding https://0e64-78-117-86-140.ngrok-free.app -> http://localhost:8090

```
The line
```
Forwarding https://0e64-78-117-86-140.ngrok-free.app -> http://localhost:8090
```
Contains `https://0e64-78-117-86-140.ngrok-free.app` value.

This value must be used to configure callback's URL from your [Sinch dashboard](https://dashboard.sinch.com/sms/api/services)
5 changes: 5 additions & 0 deletions examples/webhooks/compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

mvn clean spotless:apply || exit 1

./mvnw clean compile || exit 1
259 changes: 259 additions & 0 deletions examples/webhooks/mvnw

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading