Skip to content

Instantly share code, notes, and snippets.

@birinder-lobana
birinder-lobana / create_dynamic_QR_code.js
Last active December 30, 2022 20:41
Create a new trackable, dynamic QR Code
// Initiate the Openscreen node SDK
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 Openscreen Dashboard
const projectId = 'YOUR PROJECT ID';
async function main() {
// Create an asset for a new listing sign being hosted for 123 Main Street
@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 / add_contacts_to_Openscreen.js
Last active September 8, 2022 14:27
Use this code to create contacts upon scanning a dynamic QR code.
// Initiate the Openscreen node SDK and include the project ID that you received 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';
async function main(){
// Create a new contact
@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 / dynamic_batch_return.json
Last active July 13, 2022 19:05
Dynamic Batch Response
{
"assets": [
{
"assetId": "59e5c13e-8ac3-499e-8d4b-5fd4abf5b2af",
"projectId": "c166f2dd-9ea8-4a79-90d5-fa6989f885e6",
"name": "Billboard 1",
"description": "Billboard at Yonge and Eglington for 123 Cherry Street Listing",
"qrCodes": [
{
"qrCodeId": "24678051-b380-4fdb-98d6-541d8d08e850",
@birinder-lobana
birinder-lobana / scan_object.json
Last active July 13, 2022 19:04
A Scan object like this one is generated after each dynamic QR code scan
{
"entityType": "get_scans_by_asset_id.response_body",
"assetId": "0a43a07c-0e57-4879-9420-332a13174458",
"numberOfScans": 1,
"scans": [
{
"entityType": "app.scan",
"created": "2021-10-07T18:38:06.616Z",
"modified": "2021-10-07T18:38:06.616Z",
"assetId": "0a43a07c-0e57-4879-9420-332a13174458",
@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 / 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",