Using the Re:amaze API to Get Conversations (with PHP examples)

by Endgrate Team 2024-07-15 4 min read

Re:amaze homepage

Introduction to Re:amaze API

Re:amaze is a comprehensive customer support platform that offers a unified inbox for managing customer interactions across various channels, including email, chat, social media, and more. It is designed to enhance customer service efficiency and improve communication between businesses and their clients.

Developers may want to integrate with the Re:amaze API to streamline customer support processes by programmatically accessing and managing conversations. For example, a developer could use the Re:amaze API to retrieve customer conversations and analyze them for sentiment or automate responses based on specific triggers.

Setting Up Your Re:amaze Test Account

Before you can start using the Re:amaze API to retrieve conversations, you'll need to set up a Re:amaze account. This will allow you to generate the necessary API token for authentication and access the platform's features.

Creating a Free Re:amaze Account

To begin, sign up for a free Re:amaze account by visiting the Re:amaze website. Follow these steps:

  • Click on the "Sign Up" button on the homepage.
  • Fill in the required information, such as your email address and password, or use the option to sign up with Google or Microsoft.
  • Follow the on-screen instructions to complete the registration process.

Once your account is created, you will have access to the Re:amaze dashboard.

Generating Your Re:amaze API Token

To interact with the Re:amaze API, you need an API token. Follow these steps to generate one:

  • Log in to your Re:amaze account and navigate to the "Settings" section.
  • Under the "Developer" menu, click on "API Token."
  • Click on "Generate New Token" to create a unique API token for your account.
  • Copy and securely store the generated token, as you will need it for API authentication.

Understanding Re:amaze API Authentication

The Re:amaze API uses HTTP Basic Auth for authentication. Ensure that all requests are made over SSL/HTTPS. When making API calls, include your login email and API token in the request header. Here's an example of how to set up a sample request using curl:

curl 'https://{brand}.reamaze.io/api/v1/conversations' \
-u {login-email}:{api-token} \
-H 'Accept: application/json'

Replace {brand}, {login-email}, and {api-token} with your specific details.

With your Re:amaze account and API token ready, you're now set to start making API calls to retrieve conversations and enhance your customer support processes.

Re:amaze authentication documentation page.
sbb-itb-96038d7

Making API Calls to Retrieve Conversations from Re:amaze Using PHP

To interact with the Re:amaze API and retrieve conversations, you'll need to use PHP to make HTTP requests. This section will guide you through setting up your PHP environment, making the API call, and handling the response.

Setting Up Your PHP Environment

Before making API calls, ensure you have the following prerequisites:

  • PHP 7.4 or higher installed on your machine.
  • Composer, the PHP package manager, to manage dependencies.

Install the guzzlehttp/guzzle package, a PHP HTTP client, using Composer:

composer require guzzlehttp/guzzle

Making the Re:amaze API Call to Get Conversations

Create a PHP script named get_conversations.php and add the following code:


<?php
require 'vendor/autoload.php';

use GuzzleHttp\Client;

$client = new Client();
$brand = 'your_brand';
$loginEmail = 'your_email@example.com';
$apiToken = 'your_api_token';

$response = $client->request('GET', "https://{$brand}.reamaze.io/api/v1/conversations", [
    'auth' => [$loginEmail, $apiToken],
    'headers' => [
        'Accept' => 'application/json',
    ],
]);

if ($response->getStatusCode() === 200) {
    $conversations = json_decode($response->getBody(), true);
    foreach ($conversations['conversations'] as $conversation) {
        echo "Subject: " . $conversation['subject'] . "\n";
        echo "Message: " . $conversation['message']['body'] . "\n";
        echo "Author: " . $conversation['author']['name'] . "\n\n";
    }
} else {
    echo "Failed to retrieve conversations. Status code: " . $response->getStatusCode();
}

Replace your_brand, your_email@example.com, and your_api_token with your specific Re:amaze details.

Running the PHP Script and Verifying the Output

Execute the script from the command line:

php get_conversations.php

If successful, you should see a list of conversation subjects, messages, and authors printed to the console.

Handling Errors and Understanding Re:amaze API Responses

Ensure you handle potential errors by checking the HTTP status code. A status code of 200 indicates success, while a 429 indicates rate limiting. For more details on error codes, refer to the Re:amaze API documentation.

By following these steps, you can effectively retrieve and manage conversations from Re:amaze using PHP, enhancing your customer support capabilities.

Re:amaze API call documentation page.

Conclusion and Best Practices for Using Re:amaze API with PHP

Integrating the Re:amaze API into your PHP applications allows you to efficiently manage customer conversations, enhancing your support capabilities. By following the steps outlined in this guide, you can retrieve and analyze conversations to improve customer interactions.

Best Practices for Secure and Efficient API Integration

  • Securely Store API Credentials: Always store your API token and login credentials securely. Consider using environment variables or secure vaults to prevent unauthorized access.
  • Handle Rate Limiting: Be mindful of the Re:amaze API rate limits. Implement logic to handle HTTP 429 responses gracefully by retrying requests after a delay. Refer to the Re:amaze API documentation for more details.
  • Optimize Data Handling: When retrieving large datasets, consider paginating results to manage memory usage effectively. Use optional parameters to filter and sort data as needed.
  • Standardize Data Formats: Ensure that data retrieved from the API is transformed and standardized to fit your application's requirements, facilitating seamless integration with other systems.

Enhance Your Integration Strategy with Endgrate

While integrating with Re:amaze is a powerful way to enhance customer support, managing multiple integrations can be complex and time-consuming. Endgrate simplifies this process by providing a unified API endpoint for various platforms, including Re:amaze. With Endgrate, you can streamline your integration efforts, allowing you to focus on your core product development.

Explore how Endgrate can transform your integration strategy by visiting Endgrate and discover how you can save time and resources while delivering an exceptional integration experience for your customers.

Read More

Ready to get started?

Book a demo now

Book Demo