Skip to content

Instantly share code, notes, and snippets.

@birinder-lobana
birinder-lobana / contact_sms_template_and_SMS.js
Last active December 30, 2022 20:37
Create Contact, SMS Template and Send SMS
// 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});
// Obtain projectId from the Openscreen Dashboard
const projectId = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
// Capture scanId from the QR code scan
const scanId = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
async function main(){
@birinder-lobana
birinder-lobana / create_contact_with_project_consent.js
Last active August 31, 2022 18:04
Create an Openscreen Contact with a project-level SMS consent.
@birinder-lobana
birinder-lobana / create_sms_template.py
Created June 28, 2022 17:09
Create SMS template in an Openscreen Project using python SDK
projectId = os.environ.get('PROJECT_ID')
sms_template = os.project(projectId).smsTemplates().create({
'body': 'Body of the message for {{asset.name}}',
'smsTemplateName': 'firstTemplate',
'responseUrl': 'https://myapp/sms-response',
'statusUrl': 'https://myapp/sms-status'
})
@birinder-lobana
birinder-lobana / get_scan_info.py
Created June 28, 2022 16:55
Get scan details after a dynamic QR code is scanned, 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')
assetId = 'xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
scans = os.asset(assetId).scans().get()
@birinder-lobana
birinder-lobana / create_contact_by_project.py
Last active June 28, 2022 16:54
Create a new contact in an Openscreen project
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_contact_by_project_id = ospro.project(projectId).contacts().create({
'firstName': 'Brian',
'lastName': 'Smith',
@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 / 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',
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_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',
@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',