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
86 changes: 86 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Sinch Java SDK — Examples

This directory provides ready-to-run examples and templates to help you get started quickly with the [Sinch Java SDK](https://github.com/sinch/sinch-sdk-java).

## Overview

| Directory | Purpose | Java |
|----------------------------------------|------------------------------------------------------------------|------|
| [`getting-started/`](#getting-started) | Minimal one-feature examples, each paired with a Sinch tutorial | 8+ |
| [`snippets/`](#snippets) | Self-contained code snippets covering every API operation | 8+ |
| [`client/`](#client) | SDK Client template application | 8+ |
| [`sinch-events/`](#sinch-events) | Spring Boot server template to process received Sinch Events | 21+ |
| [`tutorials/`](#tutorials) | Step-by-step tutorials combining multiple SDK features | 21+ |

---

## Getting Started

> **Best entry point if you are new to the SDK.**

`getting-started/` contains small, focused examples — one per feature — each matching a tutorial on [developers.sinch.com](https://developers.sinch.com).

```
getting-started/
├── conversation/
│ ├── send-text-message/
│ └── respond-to-incoming-message/
├── numbers/
│ ├── search-available/
│ ├── rent-first-available-number/
│ └── rent-and-configure/
├── sms/
│ ├── send-sms-message/
│ └── respond-to-incoming-message/
├── verification/
│ └── user-verification-using-sms-pin/
└── voice/
├── make-a-call/
└── respond-to-incoming-call/
```

Each subdirectory contains its own `README.md` with a link to the corresponding online tutorial and a pointer to the shared [client configuration](client/README.md).

---

## Snippets

`snippets/` contains individual, self-contained Java classes demonstrating a single API operation each. They are a useful reference when you need to know exactly how to call a specific endpoint.

**Covered services and operations:**

See dedicated [README](snippets/README.md) file

---

## Client

`client/` is a skeleton of application that lets you explore all SDK features through a menu-driven interface.

**Useful when** you want to experiment with several services without writing code.

See dedicated [README](client/README.md) file

---

## Sinch Events

`sinch-events/` is a Spring Boot server template for receiving and processing Sinch Events.

**Useful when** you need a starting point for a backend that reacts to inbound messages, delivery reports, call events, or verification results.

See dedicated [README](sinch-events/README.md) file

---

## Tutorials

`tutorials/` contains longer, scenario-based examples that combine multiple SDK features.

### Voice — Qualify Leads

[`tutorials/voice/capture-leads-app/`](tutorials/voice/capture-leads-app)

A Spring Boot application that initiates outbound calls from a CLI helper and processes the resulting call events on a local server. Accompanies the [Qualify Leads tutorial](https://developers.sinch.com/docs/voice/tutorials/qualify-leads/java) on the Sinch developer portal.

See the [tutorial README](tutorials/voice/capture-leads-app/README.md) for setup instructions.
1 change: 1 addition & 0 deletions examples/snippets/src/main/java/conversation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ See main [README.md](../../../../README.md) for how to execute snippets
- [conversation/contacts/Update](./contacts/Update.java)
- [conversation/contacts/Merge](./contacts/Merge.java)
- [conversation/contacts/GetChannelProfile](./contacts/GetChannelProfile.java)
- [conversation/contacts/ListIdentityConflicts](./contacts/ListIdentityConflicts.java)
- Conversations
- [conversation/conversations/List](./conversations/List.java)
- [conversation/conversations/Create](./conversations/Create.java)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* Sinch Java Snippet
*
* <p>This snippet is available at https://github.com/sinch/sinch-sdk-java
*
* <p>See https://github.com/sinch/sinch-sdk-java/blob/main/examples/snippets/README.md for details
*/
package conversation.contacts;

import com.sinch.sdk.SinchClient;
import com.sinch.sdk.domains.conversation.api.v1.ContactsService;
import com.sinch.sdk.domains.conversation.models.v1.contacts.response.IdentityConflictsListResponse;
import com.sinch.sdk.models.Configuration;
import com.sinch.sdk.models.ConversationRegion;
import java.util.logging.Logger;
import utils.Settings;

public class ListIdentityConflicts {

private static final Logger LOGGER = Logger.getLogger(ListIdentityConflicts.class.getName());

public static void main(String[] args) {

String projectId = Settings.getProjectId().orElse("MY_PROJECT_ID");
String keyId = Settings.getKeyId().orElse("MY_KEY_ID");
String keySecret = Settings.getKeySecret().orElse("MY_KEY_SECRET");
String conversationRegion = Settings.getConversationRegion().orElse("MY_CONVERSATION_REGION");

Configuration configuration =
Configuration.builder()
.setProjectId(projectId)
.setKeyId(keyId)
.setKeySecret(keySecret)
.setConversationRegion(ConversationRegion.from(conversationRegion))
.build();

SinchClient client = new SinchClient(configuration);

ContactsService contactService = client.conversation().v1().contacts();

LOGGER.info("List identity conflicts");

IdentityConflictsListResponse response = contactService.listIdentityConflicts();

LOGGER.info("Response: ");

response.iterator().forEachRemaining(f -> LOGGER.info(f.toString()));
}
}
2 changes: 1 addition & 1 deletion examples/snippets/src/main/java/sms/groups/Update.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static void main(String[] args) {
// The ID of the group to update
String groupId = "GROUP_ID";
// New name for the group
String groupName = "Updated Group Name from Java SDK";
String groupName = "Updated by Java SDK";
// Members to remove from the group
List<String> toRemove = Arrays.asList("+11111111111", "+29999999999");
// Members to add to the group
Expand Down
Loading