Skip to content

Commit bd10277

Browse files
committed
help_scout init
1 parent 5f74294 commit bd10277

File tree

7 files changed

+607
-4
lines changed

7 files changed

+607
-4
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import helpScout from "../../help_scout.app.mjs";
2+
3+
export default {
4+
key: "help_scout-add-note",
5+
name: "Add Note to Conversation",
6+
description: "Adds a note to an existing conversation in Help Scout. [See the documentation](https://developer.helpscout.com/mailbox-api/endpoints/conversations/threads/note/)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
helpScout,
11+
conversationId: {
12+
propDefinition: [
13+
helpScout,
14+
"conversationId",
15+
],
16+
},
17+
text: {
18+
propDefinition: [
19+
helpScout,
20+
"text",
21+
],
22+
},
23+
},
24+
async run({ $ }) {
25+
const response = await this.helpScout.addNoteToConversation({
26+
conversationId: this.conversationId,
27+
text: this.text,
28+
});
29+
$.export("$summary", `Successfully added note to conversation ID: ${this.conversationId}`);
30+
return response;
31+
},
32+
};
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import helpScout from "../../help_scout.app.mjs";
2+
3+
export default {
4+
key: "help_scout-create-customer",
5+
name: "Create Customer",
6+
description: "Creates a new customer record in Help Scout. [See the documentation](https://developer.helpscout.com/mailbox-api/endpoints/customers/create/)",
7+
version: "0.0.{{ts}}",
8+
type: "action",
9+
props: {
10+
helpScout,
11+
customerEmail: {
12+
propDefinition: [
13+
helpScout,
14+
"customerEmail",
15+
],
16+
},
17+
customerPhone: {
18+
propDefinition: [
19+
helpScout,
20+
"customerPhone",
21+
],
22+
},
23+
chatHandles: {
24+
propDefinition: [
25+
helpScout,
26+
"chatHandles",
27+
],
28+
},
29+
socialProfiles: {
30+
propDefinition: [
31+
helpScout,
32+
"socialProfiles",
33+
],
34+
},
35+
customerAddress: {
36+
propDefinition: [
37+
helpScout,
38+
"customerAddress",
39+
],
40+
},
41+
customerDetails: {
42+
propDefinition: [
43+
helpScout,
44+
"customerDetails",
45+
],
46+
},
47+
},
48+
async run({ $ }) {
49+
const response = await this.helpScout.createCustomer({
50+
customerEmail: this.customerEmail,
51+
customerPhone: this.customerPhone,
52+
chatHandles: this.chatHandles,
53+
socialProfiles: this.socialProfiles,
54+
customerAddress: this.customerAddress,
55+
...this.customerDetails,
56+
});
57+
58+
$.export("$summary", `Successfully created customer with email: ${this.customerEmail}`);
59+
return response;
60+
},
61+
};
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import helpScout from "../../help_scout.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "help_scout-send-reply",
6+
name: "Send Reply",
7+
description: "Sends a reply to a conversation. Be careful as this sends an actual email to the customer. [See the documentation](https://developer.helpscout.com/mailbox-api/endpoints/conversations/threads/reply/)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
helpScout,
12+
conversationId: {
13+
propDefinition: [
14+
helpScout,
15+
"conversationId",
16+
],
17+
},
18+
text: {
19+
propDefinition: [
20+
helpScout,
21+
"text",
22+
],
23+
},
24+
},
25+
async run({ $ }) {
26+
const response = await this.helpScout.sendReplyToConversation({
27+
conversationId: this.conversationId,
28+
text: this.text,
29+
});
30+
31+
$.export("$summary", `Reply sent successfully to conversation ID: ${this.conversationId}`);
32+
return response;
33+
},
34+
};
Lines changed: 190 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,197 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "help_scout",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
agentId: {
8+
type: "string",
9+
label: "Agent ID",
10+
description: "ID of the agent to whom the conversation is assigned.",
11+
},
12+
conversationId: {
13+
type: "string",
14+
label: "Conversation ID",
15+
description: "The unique identifier of the conversation.",
16+
},
17+
conversationTitle: {
18+
type: "string",
19+
label: "Conversation Title",
20+
description: "Title of the conversation.",
21+
},
22+
text: {
23+
type: "string",
24+
label: "Text",
25+
description: "The content of the note or reply.",
26+
},
27+
customerEmail: {
28+
type: "string",
29+
label: "Customer Email",
30+
description: "Email of the customer.",
31+
},
32+
customerDetails: {
33+
type: "object",
34+
label: "Customer Details",
35+
description: "Optional customer's details such as name and contact.",
36+
optional: true,
37+
},
38+
customerPhone: {
39+
type: "string",
40+
label: "Customer Phone",
41+
description: "Optional phone number of the customer.",
42+
optional: true,
43+
},
44+
chatHandles: {
45+
type: "string[]",
46+
label: "Chat Handles",
47+
description: "Optional chat handles for the customer.",
48+
optional: true,
49+
},
50+
socialProfiles: {
51+
type: "string[]",
52+
label: "Social Profiles",
53+
description: "Optional social profiles for the customer.",
54+
optional: true,
55+
},
56+
customerAddress: {
57+
type: "object",
58+
label: "Customer Address",
59+
description: "Optional address of the customer.",
60+
optional: true,
61+
},
62+
},
563
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
64+
_baseUrl() {
65+
return "https://api.helpscout.net/v2";
66+
},
67+
async _makeRequest(opts = {}) {
68+
const {
69+
$ = this,
70+
method = "GET",
71+
path = "/",
72+
headers,
73+
...otherOpts
74+
} = opts;
75+
return axios($, {
76+
...otherOpts,
77+
method,
78+
url: this._baseUrl() + path,
79+
headers: {
80+
...headers,
81+
Authorization: `Bearer ${this.$auth.oauth_token}`,
82+
},
83+
});
84+
},
85+
async createWebhook({
86+
url, events, secret,
87+
}) {
88+
return this._makeRequest({
89+
method: "POST",
90+
path: "/webhooks",
91+
data: {
92+
url,
93+
events,
94+
secret,
95+
payloadVersion: "V2",
96+
},
97+
});
98+
},
99+
async addNoteToConversation({
100+
conversationId, text,
101+
}) {
102+
return this._makeRequest({
103+
method: "POST",
104+
path: `/conversations/${conversationId}/notes`,
105+
data: {
106+
text,
107+
},
108+
});
109+
},
110+
async createCustomer({
111+
customerEmail,
112+
customerPhone,
113+
chatHandles,
114+
socialProfiles,
115+
customerAddress,
116+
...customerDetails
117+
}) {
118+
return this._makeRequest({
119+
method: "POST",
120+
path: "/customers",
121+
data: {
122+
emails: [
123+
{
124+
value: customerEmail,
125+
},
126+
],
127+
phones: customerPhone
128+
? [
129+
{
130+
value: customerPhone,
131+
},
132+
]
133+
: undefined,
134+
chats: chatHandles
135+
? chatHandles.map((handle) => ({
136+
value: handle,
137+
}))
138+
: undefined,
139+
socialProfiles: socialProfiles
140+
? socialProfiles.map((profile) => ({
141+
value: profile,
142+
}))
143+
: undefined,
144+
address: customerAddress,
145+
...customerDetails,
146+
},
147+
});
148+
},
149+
async sendReplyToConversation({
150+
conversationId, text,
151+
}) {
152+
return this._makeRequest({
153+
method: "POST",
154+
path: `/conversations/${conversationId}/reply`,
155+
data: {
156+
text,
157+
},
158+
});
159+
},
160+
async emitNewEventOnConversationAssigned({ agentId }) {
161+
const events = [
162+
"convo.assigned",
163+
];
164+
const url = "https://example.com/helpscout"; // Replace with your URL
165+
const secret = "your_secret_key"; // Generate and replace with your secret key
166+
await this.createWebhook({
167+
url,
168+
events,
169+
secret,
170+
});
171+
},
172+
async emitNewEventOnCustomerAdded() {
173+
const events = [
174+
"customer.created",
175+
];
176+
const url = "https://example.com/helpscout"; // Replace with your URL
177+
const secret = "your_secret_key"; // Generate and replace with your secret key
178+
await this.createWebhook({
179+
url,
180+
events,
181+
secret,
182+
});
183+
},
184+
async emitNewEventOnConversationCreated({ conversationTitle }) {
185+
const events = [
186+
"convo.created",
187+
];
188+
const url = "https://example.com/helpscout"; // Replace with your URL
189+
const secret = "your_secret_key"; // Generate and replace with your secret key
190+
await this.createWebhook({
191+
url,
192+
events,
193+
secret,
194+
});
9195
},
10196
},
11197
};

0 commit comments

Comments
 (0)