Need a way to send a notification for an order

After an order is posted, I need a way to send a notification about that order, especially if it’s a future order. An example would be a future order is placed for an hour from now. I would like to be able to send a notification/reminder about that order 10 minutes before it’s supposed to be picked up. Additionally, if the pickup type is curbside, I would like to be able to send a notification to let the business know the customer is there for their curbside pickup.

You can definitely read orders with our APIs and be notified up updates with webhook however we don’t have the ability to send notifications as you described. This would be something you would have to build out within your application. You may want to consider integrating with a messaging service such as Twilio for SMS notifications or Firebase Cloud Messaging (FCM) for push notifications.

Here’s a general outline of how you could approach this:

  1. Create an Order:

    • When an order is placed, use the Square Orders API to create an order.
  2. Retrieve Order Information:

    • Use the Square Orders API to retrieve information about the order, including the pickup time and items.
  3. Calculate Notification Timing:

    • Based on the pickup time of the order, calculate when to send the notification. For example, if the pickup time is in one hour and you want to send a notification 10 minutes before, calculate the timing accordingly.
  4. Send Notification:

    • Integrate with a notification service (e.g., Twilio, FCM) to send notifications. Send a notification to the customer about their upcoming order and, if applicable, send a notification to the business for curbside pickup.

Here’s a simplified example in Python using the Square Python SDK and Twilio for SMS notifications:

import squareconnect
from import ApiException
from import Client
from datetime import datetime, timedelta

# Set up Square API credentials
square_access_token = 'YOUR_SQUARE_ACCESS_TOKEN'
square_location_id = 'YOUR_SQUARE_LOCATION_ID'

# Set up Twilio credentials
twilio_account_sid = 'YOUR_TWILIO_ACCOUNT_SID'
twilio_auth_token = 'YOUR_TWILIO_AUTH_TOKEN'
twilio_phone_number = 'YOUR_TWILIO_PHONE_NUMBER'

# Set up Square client
square_client = squareconnect.ApiClient(squareconnect.Configuration().set_access_token(square_access_token))

# Set up Twilio client
twilio_client = Client(twilio_account_sid, twilio_auth_token)

# Function to send SMS notification
def send_sms_notification(to, message):

# Function to handle order and send notifications
def handle_order(order_id):
        # Retrieve order information from Square
        order_api = squareconnect.OrdersApi(square_client)
        order = order_api.retrieve_order(square_location_id, order_id)

        # Extract order details
        pickup_time = datetime.strptime(order['pickup_at'], '%Y-%m-%dT%H:%M:%S.%fZ')
        current_time = datetime.utcnow()

        # Calculate time difference for notification
        time_difference = pickup_time - current_time
        notification_time = pickup_time - timedelta(minutes=10)

        # Check if it's time to send a notification
        if current_time >= notification_time:
            customer_phone = order['customer']['phone_number']

            # Send notification to the customer
            send_sms_notification(customer_phone, f"Your order will be ready in 10 minutes at {pickup_time}")

            # Check if it's a curbside pickup and notify the business
            if order.get('fulfillments'):
                for fulfillment in order['fulfillments']:
                    if fulfillment['type'] == 'PICKUP':
                        business_phone = 'BUSINESS_PHONE_NUMBER'
                        send_sms_notification(business_phone, "A customer is here for curbside pickup.")

    except ApiException as e:
        print(f"Square API error: {e}")

# Example usage
order_id = 'YOUR_ORDER_ID'

Please note that you need to replace placeholder values like 'YOUR_SQUARE_ACCESS_TOKEN', 'YOUR_TWILIO_ACCOUNT_SID', etc., with your actual credentials. Additionally, adjust the code based on your specific requirements and the programming language you’re using. :slightly_smiling_face:

While I appreciate you taking the time to respond and provide these details, I know how to send a notification outside of Square. My goal in my post wasn’t to get help on how to do that, my goal was to submit a feature request, which is why I posted this in the feature request board. Your SMS example isn’t practical, because I would have to know the phone number of everyone working and when they are working. That’s why if I’m able to send the notification directly to Square, so it doesn’t matter who is working, they will get the notification the same way they were alerted of the order coming in, that’s the ideal situation. That’s my feature request!

If the device your sending the notifications to is the shared device that the employees use and has the Square app on then it would work to push some sort of notification. Otherwise at this time there isn’t a way to trigger custom notifications within the Square app. We’re constantly working to improve our features based on feedback like this, so I’ll be sure to share your request to the API product team. :slightly_smiling_face:

Thank you! That was my goal with my post, simply to put in the feature request. I appreciate your help with that.