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
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,13 @@ Example of webhook implementation using Flask:
For 2FA quick start guide please check [these examples](two-factor-authentication.md).

#### Calls
For Calls quick start guide please check [these examples](calls.md)
For Calls quick start guide please check [these examples](calls.md).

#### Email
For Email quick start guide, view [these examples](email.md).

#### Moments
For Moments quick start guide, view [these examples](moments.md).

## Ask for help

Expand Down
68 changes: 68 additions & 0 deletions email.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Email API example

This example demonstrates how to use the [Infobip Email API](https://www.infobip.com/docs/api/channels/email). You'll learn how to initialize an email client,
send a message, and receive a delivery report.

Initialize Send Email API client:

```python
from infobip_api_client.api_client import ApiClient, Configuration

client_config = Configuration(
host="<YOUR_BASE_URL>",
api_key={"APIKeyHeader": "<YOUR_API_KEY>"},
api_key_prefix={"APIKeyHeader": "<YOUR_API_PREFIX>"},
)

api_client = ApiClient(client_config)
api_instance = EmailApi(api_client)
```

Before sending an email message, you need to verify the domain with which you will be sending emails.

## Send an Email with a file

Fields `from`, `to`, and `subject` are required. The message must also contain at least one of these: `text`, `html`, or `templateId`.

---
**IMPORTANT NOTE**

Keep in mind the following restrictions while using a trial account:

- you can only send messages to verified email addresses,
- you can only use your email address with the Infobip test domain in the following form: `YourUserName@selfserviceib.com`

---

```python
file_attachment = open("report.csv", "rb")
file_content = file_attachment.read()

api_response = api_instance.send_email(
to=["john.smith@somedomain.com"],
var_from="Jane Smith <jane.smith@somecompany.com>",
subject="Mail subject text",
text="Test message with a file",
attachment=[file_content],
)
```

## Delivery reports

For each message that you send out, we can send you a delivery report in real time.
All you need to do is specify your endpoint when sending email in the `notifyUrl` field.

Additionally, you can use a `messageId` or a `bulkId` autogenerated in a response for troubleshooting and to fetch reports.

```python
bulk_id = "BULK-ID-123-xyz";
number_of_reports_limits = 10;


api_response = api_instance.get_email_delivery_reports(
bulk_id=bulk_id, limit=number_of_reports_limits
)

for report in api_response.results:
print(f"{report.message_id} - {report.status.name}")
```
126 changes: 126 additions & 0 deletions moments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Moments quickstart

This quick guide aims to help you start with [Infobip Moments API](https://www.infobip.com/docs/api/customer-engagement/moments). After reading it, you should know how to use Moments.

The first step is to create an `ApiClient` instance with some configuration.

```python
from infobip_api_client.api_client import ApiClient, Configuration

client_config = Configuration(
host="<YOUR_BASE_URL>",
api_key={"APIKeyHeader": "<YOUR_API_KEY>"},
api_key_prefix={"APIKeyHeader": "<YOUR_API_PREFIX>"},
)

api_client = ApiClient(client_config)
```

## Flow API

You can now create an instance of `FlowApi` which allows you to manage your flows.

````python
from infobip_api_client.api import FlowApi

api_instance = FlowApi(api_client)
````
### Add participants to flow

To add participants to a flow, you can use the following code:

````python
from infobip_api_client import (
FlowAddFlowParticipantsRequest,
FlowParticipant,
FlowPersonUniqueField,
FlowPersonUniqueFieldType,
)

campaign_id = 200000000000001

request = FlowAddFlowParticipantsRequest(
participants=[
FlowParticipant(
identify_by=FlowPersonUniqueField(
identifier="test@example.com", type=FlowPersonUniqueFieldType.EMAIL
),
variables={"orderNumber": 1167873391},
),
],
notify_url="https://example.com"
)

api_response = api_instance.add_flow_participants(campaign_id, request)
````

### Get a report on participants added to flow

To fetch a report to confirm that all persons have been successfully added to the flow, you can use the following code:

````python
given_operation_id = "03f2d474-0508-46bf-9f3d-d8e2c28adaea"

api_response = api_instance.get_flow_participants_added_report(campaign_id, given_operation_id)
````

### Remove person from flow

To remove a person from a flow, you can use the following code:

````python
external_id = "8edb24b5-0319-48cd-a1d9-1e8bc5d577ab"

api_response = api_instance.remove_people_from_flow(campaign_id=campaign_id, external_id=external_id)
````


## Forms API

You can now create an instance of `FormsApi` which allows you to manage your forms.

````python
from infobip_api_client.api import FormsApi

api_instance = FormsApi(api_client)
````

### Get forms

To get all forms, you can use the following code:

````python
api_response = api_instance.get_forms()
````

### Get form by ID

To get a specific form by ID, you can use the following code:

````python
form_id = "cec5dfd2-4238-48e0-933b-9acbdb2e6f5f"

api_response = api_instance.get_form(form_id)
````

### Increment form view count

To increase the view counter of a specific form, you can use the following code:

````python
api_response = api_instance.increment_view_count(form_id)
````

### Submit form data

To submit data to a specific form, you can use the following code:

````python
form_data_request = {
"first_name": "John",
"last_name": "Doe",
"company": "Infobip",
"email": "info@example.com"
}
api_response = api_instance.submit_form_data(form_id, form_data_request)
````
Loading