Phone ID - Tutorial: Use Contact Match with Telesign Python 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 Python 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
  • Python 3.9.6

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

Set up your project

  1. Follow the Telesign Full-service Python 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.py and open it in your editor.

    touch phone_id_contact_match.py
    

Make a Contact Match request

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

  2. Import these dependencies from the SDK.

    from __future__ import print_function
    from telesignenterprise.phoneid import PhoneIdClient
    import os
    
  3. Define variables to store your authentication credentials.

    customer_id = os.getenv('CUSTOMER_ID', 'FFFFFFFF-EEEE-DDDD-1234-AB1234567890')
    api_key = os.getenv('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 = os.getenv('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 = "The first name you are matching for."
    last_name = "The last name you are matching for."
    
  6. Instantiate a PhoneIdClient object containing your Customer ID and API Key.

    phoneid = PhoneIdClient(customer_id, api_key)
    
  7. Make the request and capture the response.

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

    print(response.body)
    

Test your integration

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

    python phone_id_contact_match.py
    

Sample code

from __future__ import print_function
from telesignenterprise.phoneid import PhoneIdClient
import os

customer_id = os.getenv('CUSTOMER_ID', 'FFFFFFFF-EEEE-DDDD-1234-AB1234567890')
api_key = os.getenv('API_KEY', 'ABC12345yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==')  
phone_number = os.getenv('PHONE_NUMBER', '11234567890')
first_name = "The first name you are matching for."
last_name = "The last name you are matching for."

phoneid = PhoneIdClient(customer_id, api_key)

response = phoneid.phoneid(phone_number, addons={ "contact_match":{"first_name":first_name, "last_name":last_name}})
print(response.body)