Skip to content

Instantly share code, notes, and snippets.

View shanwixcode's full-sized avatar
🏠
Working from home

Shan shanwixcode

🏠
Working from home
View GitHub Profile
import {ask_gpt, initiate_gpt} from 'backend/openai.js';
import wixChatBackend from 'wix-chat-backend';
import wixData from 'wix-data';
export function wixChat_onMessage(event) {
if(event.direction === 'VisitorToBusiness') {
console.log('Chat was commenced');
commence(event);
}
}
import {fetch} from 'wix-fetch';
const key = "";
export async function initiate_gpt(user) {
const parameters = {
model: 'text-davinci-003',
prompt: 'You are a customer support agent for an online store selling women apparel. Please respond to customers reaching out with queries.',
max_tokens: 100,
n: 1,
import wixData from 'wix-data';
let options = {
"suppressAuth": true
};
export function wixLoyalty_onAccountCreated(event) {
const contactId = event.entity.contactId;
let object = {
loyaltyId: event.entity._id,
const accountSid = '';
const authToken = '';
const client = require('twilio')(accountSid, authToken);
import wixData from 'wix-data';
import {award_points} from 'backend/member.js';
let options = {
"suppressAuth": true
};
import {accounts} from 'wix-loyalty.v2';
import * as wixAuth from 'wix-auth';
export async function award_points(loyalty_id, options) {
try {
const elevated_earnpoints = wixAuth.elevate(accounts.earnPoints);
const account = await elevated_earnpoints(loyalty_id, options);
return account;
} catch (error) {
console.log(error);
import {authentication} from 'wix-members-backend';
export function register(object) {
return authentication.register(object.email, object.password, object.options)
.then( (registrationResult) => {
return registrationResult;
})
.catch( (error) => {
return error;
});
import {verify, verify_code} from 'backend/twilio.jsw';
import wixLocation from 'wix-location';
import {currentMember} from 'wix-members';
let me;
$w.onReady(function () {
currentMember.getMember()
.then( (member) => {
me = member._id;
import {register} from 'backend/mem-reg.jsw';
import {authentication} from 'wix-members';
import wixLocation from 'wix-location';
$w.onReady(function () {
});
export function register_click(event) {
if($w("#fname").valid && $w("#lname").valid && $w("#email").valid && $w("#pwd").valid) {
import {mediaManager} from 'wix-media-backend';
import {bufferEncode} from './sendgrid';
export function getFileUrl(fileId) {
return mediaManager.getFileUrl(fileId);
}
export function sendMail(url, email, subject, body, filename, filetype) {
return bufferEncode(url, email, subject, body, filename, filetype);
}
import {fetch} from 'wix-fetch';
import sgMail from '@sendgrid/mail';
var api_key = 'XXXXXX';
export function bufferEncode(url, email, subject, body, filename, filetype) {
return createBuffer(url)
.then( (buf) => {
return sendEmail(buf, email, subject, body, filename, filetype);
});