In this article we are going to be creating a new workflow that we will specifically use to check if our contacts phone numbers are "wireless" or if they are a landline.
Once we have everything created we will be able to simply "enroll" our contacts into this new workflow at any time to look up their phone number. Within this article we will be breaking down the process into multiple sections to make it easier to follow.
You will want to have some basic understanding of how to upload or add contacts into your system as we won't cover the specific details in this article. See the "Contacts" article for more details on uploading or adding contacts to your system.
Creating a number Set
First thing we will want to do is create a number set. If you already have an existing number set then you can skip this section and move on to the next section.
Anytime you create a workflow, it requires a "number set". Number sets are simply groups of numbers that will be used to send out the SMS or make phone calls from your workflow, if your workflow is setup to perform those actions.
In our case, we technically will not be sending out any SMS or making any phone calls that would require phone numbers, but we still are require to have a number set. We won't be adding any numbers to this number set as that is not going to be needed for our setup.
- Within your API portal, click on "Numbers" section
- Click on "Number Sets"
- Click on "Create number Set"
- Within the Number set name section enter the words "Carrier Lookup Workflow"
- Click the "Create" button
Creating a Connection to Ytel API
Connections are used to authenticate our information with the API that we will be using. We will be using our v4 API which uses a Bearer token as our authentication method. This means we will first need to create a new Bearer token.
Creating a Bearer Token
The Bearer Token we will be creating is no different than a password. Meaning keep this unique code safe as anyone who has your bearer token will be able to use it for any API calls on your account.
- Within your API portal, click on the Settings option
- Click on the API Tokens section
- Ensure you are in the Ytel API v4 tab
- Click on the Create token button
- Give your Token a Name and either set it to never expire or select a future date and time for the token to expire (if you select a future expiration date, then you will need to create a new token once that date and time hits).
- Click on Confirm
- You will receive a Token successfully generated! prompt
- Click on the copy key to clipboard button to copy your token
Important: Once your token has been created and you close the window, you will NOT be able to see this token again. If you will need to have a copy of this token for future use it will be important to save this information in a secure location on your computer such as a password manager tool. Again treat this like any other password!
Creating a Connection
Now that we have our Bearer token created, lets go ahead and create a new connection. We will first want to navigate to the "Connections" section within the API portal.
- Log into your API portal portal and click on Workflows
- Select Webhooks from the menu
- Click into the Connections tab
- Click on the Create Connection button
- Give the connection a Name (we will be calling ours Ytel API v4)
- In the Description we can include more details about this connection type. This simply will give us more details on what this connection does. In our case we will simply put the same information into Description as we did for the Name field.
- Click on Add authorization header
- Enter the text "Authorization" into the Key field
- Enter the text "Bearer" followed by a space and then paste in your bearer token you copied earlier into the Value field. (i.e. Bearer e12dkajadfkasdfj...)
- Under the Headers section click on Add header
- Enter in the text "Content-Type" into the Key field
- Enter the text "application/json" into the Value field
- Press the Save button
Note: Do not include quotes in the text boxes.
We have now successfully created a Connection to our v4 API. Keep in mind that we can now use this connection not only on the carrier look up Webhook we are about to create, but any other Ytel Webhook we might create in the future as long as we are using our v4 API calls.
Creating a Webhook for our Carrier Lookup API
With the connection out of the way, let's go ahead and create a Webhook for our Carrier Lookup API. For more information on our Carrier Lookup API please refer to our API documentation.
- Log into your API portal and click on Workflows
- Select Webhooks from the menu
- Press the Create webhook button
- We will be entering "Ytel CarrierLookup" into the Name field
- Select the "Ytel API v4" connection from the drop down menu of the Connection setting
- For Method we will be using a "GET"
- For the Request URL we will be entering in the following URL "https://api-beta.ytel.com/api/v4/carrier/lookup/PHONENUMBER1/"
- We can skip the Content type, Event type, Headers and Request Body as that information is not needed for our Carrier Lookup API.
- Under the "Response processing" section, enter the text "$.status" into the Success path field.
- Enter the text "true" into the Success value field.
- Within the "Response variables" section we will be adding all the information we wish to retrieve from the response our Carrier Lookup API will return (Scroll down below the steps to see an example of the response and the data our carrier lookup API returns.).
- Let's go ahead and add the "wireless" field and the "network" field to our contacts that will be running through this workflow.
- Click on "Add variable".
- Enter the text "wireless" within the Variable name field (this will be the variable name we will be using in our workflow that will house the information we need. We could put any word we want in this field. We could even use the word "pizza" if we really wanted to).
- Enter the text "$.payload.wireless" within the Path field (here we are telling it that we are interested in the value the API returns that associated with the "wireless" field).
- Let's add the "network" field next.
- Click on "Add variable".
- Enter the text "network" within the Variable name field.
- Enter the text "$.payload.network" into the Path field.
- Press the "Save" button.
Example Response from our Carrier Lookup API
"network": "Cellco Partnership dba Verizon Wireless - CA",
Creating our Carrier Lookup Workflow
Now that our webhook is completed, we can create our "Carrier Lookup" Workflow which we will use to run our contacts through in order to obtain the wireless and network data for the contact.
- Log into your API portal and click on Workflows.
- Click on the "Create workflow" button.
- For the Title we will be calling it "Ytel Carrier Lookup".
- Select your "Number Set" from the Select number set drop down menu
- For the Timezone protection let's select "None"
- Click on "Create"
- Click the "+" symbol and select the "Webhook" node
- Within the "Webhook" node select the Webhook we created earlier in the article.
- Click the "+" symbol on the Webhook node and select the "Edit Contact" node.
- We are going to be selecting Assign Value from Campaign from the drop down menu.
- Within variable text box enter in the word "wireless" (this will be the field on the contact that will be associated with the data we want. We could use an existing attribute or we can put whatever name we would like here and the system will add the attribute to the contact automatically if it does not exist.).
- Within the value text box enter in the word "wireless". Remember this is the variable name we set earlier on the webhook. If we had used the word "pizza" as I mentioned earlier, then we would enter the word "pizza" here. This essentially holds the variable data.
- Go through steps 11 and 12 again, but change the word "wireless" to "network", so we can capture that data as well.
- Click the "+" symbol and select the "Stop" node
Running your Contacts through your Carrier Lookup Workflow
The hard part is now done and behind us.
- Navigate to the "Contacts" section and select one or more of your contacts you wish to run through this API.
- Click on the "Start workflow" button
- Select your Carrier Lookup workflow from the drop down menu
- Click on "Enroll"
Final Remarks/Thoughts/Words of Wisdom's
Creating a Connection and a Webhook might seem like a lot of steps at first, but once you understand how to create webhooks it greatly opens up all the possibilities and things you can accomplish when connecting API's together.
A few important things to keep in mind..
- Once a contact or a group of contacts are "enrolled" into an active workflow, for all intensive purposes you cannot stop a workflow. It must runs it's course.
- Some of our API's (such as the Carrier Lookup API) has a cost associated with it on a per use basis. This means if you are paying 0.003 per carrier lookup then each time you run a contact through this workflow your will be charged for the look up.
- When creating a Bearer token, make sure to keep it safe and treat it like any other password. If the Bearer token becomes compromised you can always delete it, so it is no longer active.