This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns learnclojure.fizzbuzz) | |
(defn fun [x] | |
(if | |
(and (= (mod x 3) 0) (= (mod x 5) 0)) | |
"fizzbuzz" | |
(if | |
(= (mod x 3) 0) | |
"fizz" | |
(if |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { parse } = require('json2csv'); | |
const fs = require('fs'); | |
const data = require('./conversations.json'); | |
const messages = []; | |
for (const entry of data) { | |
for (const message of entry.messages) { | |
messages.push(Object.assign({ | |
conversation_id: entry.conversation._id, | |
role: message.role, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const get = (appId, before) => fetch(`https://app.smooch.io/webapi/apps/${appId}/logs?before=${before}`, {"credentials":"include","headers":{"accept":"application/json","accept-language":"en-US,en;q=0.9,fr;q=0.8","content-type":"application/json","sec-fetch-mode":"cors","sec-fetch-site":"same-origin","x-requested-with":"XMLHttpRequest"},"referrer":`https://app.smooch.io/apps/${appId}/logs`,"referrerPolicy":"no-referrer-when-downgrade","body":null,"method":"GET","mode":"cors"}); | |
async function getFailedMessages(appId, ts, failedMessages=[]) { | |
console.log(ts, failedMessages.length); | |
const data = await get(appId, ts).then(res => res.json()); | |
const messages = data.events | |
.filter(event => event.type === 'webhook') | |
.filter(event => event.status === 'failed') | |
.filter(event => event.details.trigger === 'message:appUser') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
How to: | |
Run this script with node and pass filepath and username + password as command line args: | |
node script.js "./YOUR_CSV_FILE" ACCOUNT_KEY ACCOUNT_SECRET | |
e.g., | |
node script.js "./apps.csv" act_5964f00fc26cb5516693ebf5 cUQIis8kGtVZNg6eWoZrvk... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Run this script by logging into your Smooch dashboard, | |
navigating to the app for which you want to collect logs, | |
and pasting the script into the JavaScript console. | |
The output is a global variable called `results`. | |
*/ | |
async function getLogs(ts=undefined, hasMore=true, events=[]) { | |
const appId = location.pathname.split('/')[2]; | |
ts = ts || Date.now() / 1000; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* What is the problem we're trying to solve? | |
* Sometimes a business needs additional information to be part of the record in Support. | |
* Solution: use a service to handle events sent from Zendesk via a target, parse some info from the event and insert a comment into the ticket with some additional context. | |
* The real meat and potatoes, which you have to developm is what happens between receiving the event and inserting the comment. | |
*/ | |
// imports | |
const bodyParser = require('body-parser'); | |
const express = require('express'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const bodyParser = require('body-parser'); | |
const Smooch = require('smooch-core'); | |
const APP_ID = ''; | |
const KEY_ID = ''; | |
const SECRET = ''; | |
const outboundMessageLogs = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
app = Flask(__name__) | |
@app.route('/', methods=['HEAD']) | |
def head(): | |
return 'OK' | |
@app.route('/events', methods=['POST']) | |
def post(): | |
return 'OK' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// `createElement` and `createComponent` comprise the entire framework | |
const createElement = elementName => (props={}, children=[]) => { | |
const element = document.createElement(elementName); | |
Object.assign(element, props); | |
for (const child of children) { | |
element.appendChild(child); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function getIds(ts, ids = []) { | |
const id = location.pathname.split('/')[2]; | |
const query = ts ? `?before=${ts}` : ''; | |
const url = `https://app.smooch.io/webapi/apps/${id}/logs${query}`; | |
const response = await fetch(url, { | |
"credentials": "include", | |
"headers": { | |
"accept": "application/json", | |
"accept-language": "en-US,en;q=0.9", |