Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f8c3036
Use v2 card in getting started project
brandenrodgers Aug 4, 2022
e1c7284
update error handling. Add simple readme
brandenrodgers Aug 5, 2022
73b5d0e
update comment
brandenrodgers Aug 5, 2022
2535a75
Merge branch 'main' into use-v2-card
brandenrodgers Aug 9, 2022
5c24f21
POC example typescript getting started project
brandenrodgers Aug 9, 2022
45d44b6
example of a pre upload script
brandenrodgers Aug 10, 2022
cac4d29
add basic type example
brandenrodgers Aug 10, 2022
f92ca6e
test gh action
brandenrodgers Aug 11, 2022
5ca2ba5
fix action syntax
brandenrodgers Aug 11, 2022
f85b9de
try install
brandenrodgers Aug 11, 2022
e4cf280
HubSpot Build & Commit
brandenrodgers Aug 11, 2022
a34a9f3
rename dist folder
brandenrodgers Aug 11, 2022
cd3082f
Merge branch 'typescript-example' of github.com:HubSpot/getting-start…
brandenrodgers Aug 11, 2022
d02b8f0
config update
brandenrodgers Aug 11, 2022
9c87ecf
HubSpot Build & Commit
brandenrodgers Aug 11, 2022
8bc02f1
force add dist
brandenrodgers Aug 11, 2022
889652d
HubSpot Build & Commit
brandenrodgers Aug 11, 2022
77ff09a
maybe this works
brandenrodgers Aug 11, 2022
418ac9f
specify forced dir
brandenrodgers Aug 11, 2022
4f85f10
this?
brandenrodgers Aug 11, 2022
e672a48
HubSpot Build & Commit
brandenrodgers Aug 11, 2022
c174b86
only run on merge
brandenrodgers Aug 11, 2022
bf6482a
Merge branch 'typescript-example' of github.com:HubSpot/getting-start…
brandenrodgers Aug 11, 2022
8b16db7
remove dist folder
brandenrodgers Aug 11, 2022
f509802
switch back to dist
brandenrodgers Aug 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Build Project & Commit
on:
pull_request:
types:
- closed
jobs:
build:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build Project
uses: actions/setup-node@v3
with:
node-version: '12.x'
- run: npm install
- run: npm run build --if-present
- name: Commit Changes
uses: EndBug/add-and-commit@v9
with:
add: './dist -f'
default_author: github_actor
message: 'HubSpot Action: Build Project'
pathspec_error_handling: exitImmediately
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
# getting-started-project-template
# getting-started-project-template

This is the Getting Started project for HubSpot developer projects. This repo contains code that is intended to help developers to get up and running with developer projects quickly and easily.

## Requirements
There are a few things that must be set up before you can make use of this getting started project.
- You must have an active HubSpot account.
- You must have the [HubSpot CLI](https://www.npmjs.com/package/@hubspot/cli) installed and set up.
- You must have access to developer projects (developer projects are not currently available to the public).

## Usage
The HubSpot CLI is configured to pull from the latest release of this project. To get started, run the following CLI command in your terminal:

`hs project create`

The CLI should walk you throug the rest of the setup flow.
3 changes: 2 additions & 1 deletion hsproject.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "project_name",
"srcDir": "src"
"srcDir": "dist",
"preUploadScript": "npm run build"
}
24 changes: 24 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"devDependencies": {
"@types/node": "^18.6.5",
"rsync": "^0.6.1",
"typescript": "^4.7.4"
},
"scripts": {
"copy-files": "rsync -av --exclude='*.ts' ./project/ dist",
"ts-compile": "tsc",
"build": "npm run ts-compile && npm run copy-files"
}
}
File renamed without changes.
63 changes: 63 additions & 0 deletions project/app/app.functions/crm-card.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// For external API calls
const axios = require('axios');

exports.main = async (
context: Context,
sendResponse: (a: FunctionResponse) => void
) => {

// Store contact firstname, configured as propertiesToSend in crm-card.json
const { firstname } = context.propertiesToSend;

const introMessage = {
type: "text",
format: "markdown",
text: "_An example of a CRM card extension that displays data from Hubspot, uses ZenQuotes public API to display daily quote, and demonstrates custom actions using serverless functions._",
};

try {
const { data } = await axios.get("https://zenquotes.io/api/random");

const quoteSections = [
{
type: "tile",
body: [
{
type: "text",
format: "markdown",
text: `**Hello ${firstname}, here's your quote for the day**!`
},
{
type: "text",
format: "markdown",
text: `**Quote**: ${data[0].q}`
},
{
type: "text",
format: "markdown",
text: `**Author**: ${data[0].a}`
}
]
},
{
type: "button",
text: "Get new quote",
onClick: {
type: "SERVERLESS_ACTION_HOOK",
serverlessFunction: "crm-card"
}
}
];

sendResponse({ sections: [introMessage, ...quoteSections] });
} catch (error) {
// "message" will create an error feedback banner when it catches an error
sendResponse({
message: {
type: 'ERROR',
body: `Error: ${error.message}`
},
sections: [introMessage]
});
}
};
7 changes: 4 additions & 3 deletions src/app/app.json → project/app/app.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "App",
"description": "",
"name": "Example App",
"description": "An example private app that contains a single CRM card extension.",
"scopes": [
"crm.objects.contacts.read",
"crm.objects.contacts.write"
Expand All @@ -10,7 +10,8 @@
"crm": {
"cards": [
{
"file": "./crm-card.json"
"file": "./crm-card.json",
"version": "2"
}
]
}
Expand Down
17 changes: 17 additions & 0 deletions project/app/crm-card.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"type": "crm-card",
"version": "2",
"data": {
"title": "Example CRM Card",
"fetch": {
"targetFunction": "crm-card",
"objectTypes": [
{
"name": "contacts",
"propertiesToSend": ["firstname"],
"actions":[]
}
]
}
}
}
14 changes: 14 additions & 0 deletions project/types/main.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Context types
interface PropertiesToSend {
firstname: String;
}

interface Context {
propertiesToSend: PropertiesToSend;
}

// Function Response types
interface FunctionResponse {
sections?: Array<object>;
message?: { type: string; body: string };
}
74 changes: 0 additions & 74 deletions src/app/app.functions/crm-card.js

This file was deleted.

46 changes: 0 additions & 46 deletions src/app/crm-card.json

This file was deleted.

6 changes: 6 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"outDir": "dist",
"rootDir": "./project"
}
}