Skip to content

Instantly share code, notes, and snippets.

@birinder-lobana
birinder-lobana / creating_sms_template.js
Created May 3, 2022 17:48
Create a new SMS template. This allows you to send SMS to any Openscreen contact containing a valid phone number.
// Initiate the Openscreen node SDK and include the project ID that you recieved using the Openscreen dashboard
const { Openscreen } = require("@openscreen/sdk");
require('dotenv').config();
const os = new Openscreen().config({key: process.env.OS_API_KEY, secret: process.env.OS_API_SECRET});
const projectId = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
const scanId = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
async function main(){
@birinder-lobana
birinder-lobana / send_sms.js
Created May 3, 2022 17:53
Send SMS using Openscreen SDK to a contact using an SMS template.
// Initiate the Openscreen node SDK and include the project ID that you recieved using the Openscreen dashboard
const { Openscreen } = require("@openscreen/sdk");
require('dotenv').config();
const os = new Openscreen().config({key: process.env.OS_API_KEY, secret: process.env.OS_API_SECRET});
const projectId = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
const scanId = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
async function main(){
@birinder-lobana
birinder-lobana / scan_object.json
Last active May 10, 2022 18:29
Retrieve Scans response
{
"entityType": "app.scan",
"created": "2021-10-07T18:38:06.616Z",
"modified": "2021-10-07T18:38:06.616Z",
"assetId": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"scanId": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"projectId": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"qrCodeId": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"ipAddress": "xx.xxx.xxx.xx",
"scanTime": "2021-10-07T18:38:05.557Z",
@birinder-lobana
birinder-lobana / authentication.py
Created June 23, 2022 19:16
Authenticate your python application
from openscreen import Openscreen
import os
#Obtain your access key and secret from Openscreen Dashboard
ospro = Openscreen(access_key=os.environ.get('OS_ACCESS_KEY'), access_secret=os.environ.get('OS_ACCESS_SECRET'))
#Create a new project on Openscreen Dashboard. Paste the projectId below
projectId = os.environ.get('PROJECT_ID')
@birinder-lobana
birinder-lobana / create_asset_and_qr_code.py
Last active June 27, 2022 16:00
Create an Asset and a QR Code using Openscreen's python SDK
from openscreen import Openscreen
import os
#Obtain your access key and secret from Openscreen Dashboard
ospro = Openscreen(access_key=os.environ.get('OS_ACCESS_KEY'), access_secret=os.environ.get('OS_ACCESS_SECRET'))
#Create a new project on Openscreen Dashboard. Paste the projectId below
projectId = os.environ.get('PROJECT_ID')
#Create an Asset with a QR code
my_asset_response = ospro.project(projectId).assets().create({
'name': '123 Main Steet Sign',
@birinder-lobana
birinder-lobana / create_contact_by_scan.py
Last active June 27, 2022 16:12
Create an Openscreen contact against a QR Code scan.
scanId = 'SCANID_FROM_YOUR_APPLICATION'
create_contact_by_scan_id = ospro.scan(scanId).contacts().create({
'firstName': 'Brian',
'lastName': 'Smith',
'emailAddress': 'bsmith@test.com',
'mailingAddress': {
'address': '123 Street',
'city': 'Toronto',
'provinceOrState': 'ON',
scanId = create_contact_by_scan_id.contact.customAttributes[0]
contactId = create_contact_by_scan_id.contact.contactId
sms = ospro.scan(scanId).sms().send({
# You may use an SMS template to send SMS or pass the body as plain text
'body': 'Congratulations! You are the winner of our campaign',
'contactId': contactId
})
@birinder-lobana
birinder-lobana / create_static_QR_code.py
Created June 28, 2022 15:40
Create a Static QR code using Python SDK
from openscreen import Openscreen
import os
#Obtain your access key and secret from Openscreen Dashboard
ospro = Openscreen(access_key=os.environ.get('OS_ACCESS_KEY'), access_secret=os.environ.get('OS_ACCESS_SECRET'))
#Create a new project on Openscreen Dashboard. Paste the projectId below
projectId = os.environ.get('PROJECT_ID')
#Create an Asset with a QR code
my_asset_response = ospro.project(projectId).assets().create({
'name': '123 Main Steet Sign',
@birinder-lobana
birinder-lobana / create_batch_qr_codes.py
Last active June 28, 2022 15:55
Create multiple dynamic QR Codes using python SDK
from openscreen import Openscreen
import os
#Obtain your access key and secret from Openscreen Dashboard
ospro = Openscreen(access_key=os.environ.get('OS_ACCESS_KEY'), access_secret=os.environ.get('OS_ACCESS_SECRET'))
#Create a new project on Openscreen Dashboard. Paste the projectId below
projectId = os.environ.get('PROJECT_ID')
create_assets_by_project_id = ospro.project(projectId).assetsBatch().create([{
'name': 'Billboard 1',
'description': 'Billboard at Yonge and Eglington for 123 Cherry Street Listing',
@birinder-lobana
birinder-lobana / contact.json
Last active June 28, 2022 16:47
The contact object which can be pre-loaded in Openscreen database or captured after a dynamic QR code is scanned and redirected to a web-form.
"contact": {
"contactId": "864422e9-0741-43e6-8b73-b46ea0c0cc16",
"firstName": "Brian",
"lastName": "Smith",
"emailAddress": "bsmith@test.com",
"mailingAddress": {
"address": "123 Street",
"city": "Toronto",
"provinceOrState": "ON",
"country": "Canada",