Phone ID - Tutorial: Use Contact Match with Telesign Ruby SDK

📘

NOTE:

To add Contact Match to your account, contact a Telesign expert. This feature is available for full-service accounts only.

This tutorial describes how to use the Phone ID Contact Match identity attribute with the Telesign Ruby SDK, guiding you step-by-step through the creation of an integration that uses the Phone ID Contact Match. Skip to the end of this page to see the full sample code.

Before you begin

Make sure you have the following before you start:

  • Authentication credentials: Your Customer ID and API Key. If you need help finding these items, go to the support article How do I find my Customer ID and API Key.
  • Identity attribute enabled - Make sure the Contact Match identity attribute is enabled by Telesign. If it is not yet enabled, contact a Telesign expert.
  • Phone number - The phone number you want to get information about.

📘

NOTE:

This tutorial uses the following:

  • MacOS
  • Ruby 3.3.6

Please modify accordingly if your developer environment differs from these details.

Set up your project

  1. Follow the Telesign Full-service Ruby SDK install instructions here on GitHub incorporating these details:

    • Use phoneidTest as the project name.

    You should end up in the top-level directory for your project in the Terminal.

  2. Create a new file called phone_id_contact_match.rb and open it in your editor.

    touch phone_id_contact_match.rb
    

Make a Contact Match request

  1. Follow the steps below or copy the sample code into a file and update accordingly.

  2. Import this dependency from the SDK.

    require 'telesignenterprise'
    
  3. Define variables to store your authentication credentials.

    customer_id = ENV['CUSTOMER_ID'] || 'FFFFFFFF-EEEE-DDDD-1234-AB1234567890'
    api_key = ENV['API_KEY'] || 'ABC12345yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw=='
    
  4. Define a variable to hold the phone number you want to get information for. Use the complete number, including the country code. This should be a string with no spaces or special characters. For example: 16505551212.

    phone_number = ENV['PHONE_NUMBER'] || '11234567890'
    

    📘

    NOTE:

    In your production integration, pull the phone number from your recipient database instead of hardcoding it.

  5. Define variables to hold the first name and last name that you want to match.

    first_name = 'Put the first name you are matching for here.'
    last_name = 'Put the last name you are matching for here.'
    
  6. Instantiate a phoneid_client object containing your Customer ID and API Key.

    phoneid_client = TelesignEnterprise::PhoneIdClient.new(customer_id, api_key)
    
  7. Make the request and capture the response. Store the object, and pass it your phone number then pass the identity attribute, contact_match, that you want to use..

    response = phoneid_client.phoneid(phone_number, addons: {
        contact_match: {
            first_name: first_name,
            last_name: last_name,
        }
    })
    
  8. Display the output in the console for debugging purposes. In your production code, you would likely remove this.

    puts response.body
    

Test your integration

  1. Switch from your editor to the terminal and run:

    ruby phone_id_contact_match.rb
    

Sample code

require 'telesignenterprise'


customer_id = ENV['CUSTOMER_ID'] || 'FFFFFFFF-EEEE-DDDD-1234-AB1234567890'
api_key = ENV['API_KEY'] || 'ABC12345yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw=='

phone_number = ENV['PHONE_NUMBER'] || '11234567890'
first_name = 'Put the first name you are matching for here.'
last_name = 'Put the last name you are matching for here.'

phoneid_client = TelesignEnterprise::PhoneIdClient.new(customer_id, api_key)

response = phoneid_client.phoneid(phone_number, addons: {
    contact_match: {
        first_name: first_name,
        last_name: last_name,
    }
})

puts response.body