Integration via API

Adding a Lead/Contact via API

In order to send a lead / contact to RAIA programmatically we offer a Rest API. For example, if you wanted to send a lead from your website to RAIA real-time - you would use our API.

When you setup your BOT you will receive an API Key (which you will include in your API Call)

// The input fields for the post to our endpoint

ENDPOINT: https://raiabot.com/api/newconversation.cfm

APIKEY (required)
    Each Bot has a unique APIKey.  
SECRETKEY (required)
    Secret Key needs to be generated for the Bot.
FNAME (required)
    First Name of Contact
LNAME (required)
    Last Name of Contact
CHANNEL (defaults to SMS)
    Must be SMS or EMAIL (the method of communication bot will use)
PHONE (required for Channel SMS)
    Phone of Contact
EMAIL (required for Channel EMAIL)
    Email of Contact
SOURCE
    Source of Contact
CONTEXT
    Context of your relationship with this contact
INTRO
    The first message bot will send to contact (SMS)
INTROHTML
    The first message bot will send to contact in HTML (Email)
SUBJECT
    The subject line in the email.
FKID
    Your custom identifier (ID) for this contact (the ID you use in your system)
FKUSERID
    Your custom identifier (ID) for the contact owner (e.g. Sales Rep)

Generating a Secret Key

In order to use the API you will need the Public APIKEY that is assigned to each Bot, and also need to generate a SECRETKEY in the RAIA App to ensure the request is authenticated. You can do this under the Settings > Integration > API section.

Example form code that would deliver the lead to RAIA

// Example Form Code

<form method="post" action="https://raiabot.com/api/newlead.cfm"> 
<input type="hidden" name="APIKEY" value="  <YOUR API KEY HERE>  ">
<input type="hidden" name="SOURCE" value="Website">
<input type="hidden" name="CONTEXT" value="This lead filled out form to learn more">
<input type="hidden" name="INTRO" value="Thank you for visiting abc.com. Do you have any questions?"> 
<input type="hidden" name="CHANNEL" value="SMS">
<input type="hidden" name="ReturnURL" value="https://abc.com/success">

<input type="text" name="FName" placeholder="First Name" required><BR>
<input type="text" name="LName" placeholder="Last Name" required><BR>
<input type="text" name="Email" placeholder="Email" required><BR>
<input type="text" name="Phone" placeholder="Phone" required><BR>
<input type="Submit" value="Request More Info">
</form>

Example of posting via PHP

<?php

// Define the data to send
$data = [
    'APIKEY' => '<YOUR API KEY HERE>',
    'SOURCE' => 'Website',
    'CONTEXT' => 'This lead filled out form to learn more',
    'INTRO' => 'Thank you for visiting abc.com. Do you have any questions?',
    'CHANNEL' => 'SMS',
    'ReturnURL' => 'https://abc.com/success',
    'FName' => $_POST['FName'], // Assuming these values are obtained from a form submission
    'LName' => $_POST['LName'],
    'Email' => $_POST['Email'],
    'Phone' => $_POST['Phone']
];

// Initialize cURL session
$ch = curl_init();

// Set cURL options
curl_setopt($ch, CURLOPT_URL, 'https://raiabot.com/api/newlead.cfm');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Execute the POST request
$response = curl_exec($ch);

// Check for errors
if(curl_errno($ch)){
    echo 'Request Error:' . curl_error($ch);
}

// Close cURL session
curl_close($ch);

// Process the response
echo $response;

?>

Example in cURL

curl -X POST https://raiabot.com/api/newlead.cfm \
    -d APIKEY=<YOUR API KEY HERE> \
    -d SOURCE=Website \
    -d CONTEXT="This lead filled out form to learn more" \
    -d INTRO="Thank you for visiting abc.com. Do you have any questions?" \
    -d CHANNEL=SMS \
    -d ReturnURL=https://abc.com/success \
    -d FName=<First Name> \
    -d LName=<Last Name> \
    -d Email=<Email Address> \
    -d Phone=<Phone Number>

Last updated