/ PowerShell

PowerShell Automated Gigafiber Availability Check

A few months back I was informed Gigafiber was coming to my neighborhood. I was, of course, very happy to hear this and wanted to know as soon as it became available. So, I wrote a short script to check for availability and notify me via Telegram when it became available. Now, on the off chance someone out there is looking for something similar, I'm posting it here.

In order to keep this short, I assume you have at least a very basic knowledge of PowerShell. You should still be able to follow along if you do not, but it may require a little googling on the side.

To start, the script.

##Start User Variables
#Address Info
$zip = ''
$streetAddress = ''
$unitNumber = ''
#Telegram Info
$botToken = ''
$chatID = ''
##End User Variables

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$ErrorActionPreference = "Continue"

$json = ConvertTo-Json -Compress @{'userInputZip' = "$zip"; 'userInputAddressLine1' = "$streetAddress"; 'userInputAddressLine2' = "$unitNumber"; 'mode' = 'fullAddress'; 'customer_type' = 'Consumer'}
$uri = 'https://www.att.com/services/shop/model/ecom/shop/view/unified/qualification/service/CheckAvailabilityRESTService/invokeCheckAvailability'
$count = 0
$goodResponse = $false


while (($goodResponse -eq $false) -and ($count -lt 15)) {

    $response = Invoke-RestMethod -URI $uri -Method Post -Body $json -Headers @{"accept-encoding"="gzip, deflate, br"; "accept-language"="en-US,en;q=0.9"; "content-type"="application/json;charset=UTF-8"; "accept"="application/json, text/plain, */*"; "scheme"="https"; "method"="POST"}
    $count++
   
    if ($response.CkavDataBean.UnifiedAddressBean.UserQualifiedHomeAddress.zipCode -ne $null)

    {
        $goodResponse = $true
    
        if (($response.profile.isGIGAFiberAvailable -eq $true) -or ($response.CkavDataBean.maxHsiaSpeedAvailable -match '1000') -and ($botToken -ne ''))
        {
            $telegramURI = ("https://api.telegram.org/bot" + $botToken + "/sendMessage")
            $telegramJson = ConvertTo-Json -Compress @{chat_id = $chatID; text='Woo! Fiber is finally avaliable! Go here to sign up: https://www.att.com/internet/fiber.html'}
            $telegramResponse = Invoke-RestMethod -Uri $telegramURI -Method Post -ContentType 'application/json;charset=utf-8' -Body $telegramJson
        }
    }

    else {Start-Sleep -Seconds 2.5}
}

if ($count -eq 15)

{
    Write-Output 'Bad response returned 15 times, stopping.'
}

Take the above and copy/paste it into a text editor (or ISE).

In order to ensure your address matches what ATT has, I'd first visit the availability lookup page (here) to see how it formats your street address.

Next fill out the variables zip, street address, and (if you have one), unit number.

After doing so, execute the script. If you're using ISE you can just hit F5, if you're using a text editor save the file with the extension .ps1, then open PowerShell and type $result = pathtoscript.ps1 and hit enter.

If it took a while to execute and you got this output, Bad response returned 15 times, stopping., your address information likely didn't match something ATT was able to look up. I suggest visiting the availability lookup page to see how ATT formats your street address.

In the same PowerShell window you already have open, type $response.CkavDataBean.UnifiedAddressBean.UserQualifiedHomeAddress. This is ATT's version of your address. If it has what looks to be your address, you should be good to proceed. If it does not, revisit the previous steps.

Now that we know your address variables are set correctly go ahead and enter your Telegram variables.
Note: You can see my guide on setting up a Telegram bot (here).

If you'd like to test and ensure Telegram is working correctly, change line 30 to if ($true). This will cause that block to always execute. Make sure to change it back when you're done.

Finally, you'll want to set this up to run at a set interval. If you're on Windows you can use Task Scheduler.

Use Local Service for the run as user.

For the trigger I would recommend setting it up to run at startup, every 15 minutes, indefinitely.

For the action, Start a program, powershell.exe, for arguments -ExecutionPolicy Bypass -NoProfile -File "pathtoscript.ps1".

Then save the task and manually execute it, it should continue to run every X minutes until you shut down. Once you boot back up it should automatically start running again.

PowerShell Automated Gigafiber Availability Check
Share this