Skip to content

Tracking package with Aftership API and send notification via Telegram

Notifications You must be signed in to change notification settings

chatainsim/aftership_telegram

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Aftership Telegram Notifier

This script uses the Aftership API to track packages and sends notifications to a Telegram chat.

Features

  • Tracks packages using the Aftership API.
  • Sends notifications to Telegram.
  • Handles different couriers.
  • Archives delivered packages.

Prerequisites

Before running the script, make sure you have the following dependencies installed:

  • curl: A command-line tool for transferring data with URLs.
  • jq: A lightweight and flexible command-line JSON processor.

You can install them using your system's package manager. For example, on Debian-based systems:

sudo apt-get update
sudo apt-get install curl jq

Configuration

  1. Create config.sh:

    Create a config.sh file in the same directory as the script and add the following content:

    #!/bin/bash
    # Aftership API
    API="YOUR_AFTERSHIP_API_KEY"
    # Telegram API
    APITELEGRAM="YOUR_TELEGRAM_BOT_API_KEY"
    # Telegram Chat ID
    CHATID="YOUR_TELEGRAM_CHAT_ID"

    Replace the placeholder values with your actual API keys and chat ID.

  2. Add Tracking Numbers:

    Open colis.conf and add your tracking numbers in the following format:

    slug;colis_number;comment
    
    • slug: The courier's slug (e.g., colissimo, ups).
    • colis_number: The tracking number of the package.
    • comment: A brief description of the package.

    Example:

    colissimo;9L12345678901;My first package
    

Usage

To run the script, execute the following command:

./aftership.sh

You can also use the display argument to print the tracking information to the console:

./aftership.sh display

Automation

To automate the tracking process, you can set up a cron job to run the script at regular intervals. For example, to run the script every 30 minutes, add the following line to your crontab:

*/30 * * * * /path/to/aftership.sh

How It Works

The script reads the tracking numbers from colis.conf, retrieves the tracking information from the Aftership API, and compares the latest checkpoint with the previous one. If there is a new update, it sends a notification to the specified Telegram chat.

When a package is marked as "Delivered," the script comments out the corresponding line in colis.conf and archives the tracking data.

About

Tracking package with Aftership API and send notification via Telegram

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages