-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
78 lines (67 loc) · 3.72 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Appmixer Embed Integrations Demo</title>
<link rel="stylesheet" type="text/css" href="./style.css">
</head>
<body>
<div class="container">
<div class="guide">
<img id="yoursaas" src="./assets/yoursaas.svg" />
<h1>Appmixer Embedded Integrations Demo</h1>
<p>This demo shows you how to embed Appmixer Integrations in your own web application.</p>
<h2>1. Try the Appmixer Integrations UI</h2>
<p>The Appmixer Integrations UI allows end-users of your application to browse and activate integrations that you pre-built for them in the Appmixer Studio.</p>
<p><b>Try it yourself and activate an integration by clicking on the integration tile and configuring the integration.</b></p>
</p>
<p class="small">Note that this integration will run in the context of an Appmixer virtual user that was created for you in the background when you opened this page.</p>
<p class="small">The Integration marketplace is rendered in the page natively, using the Appmixer JavaScript SDK. It is not included in an iframe.</p>
<h2>2. Trigger the integration by sending an App Event</h2>
<p>Once you have activated an integration, you can trigger it by sending an App Event to Appmixer (assuming your integration starts with the <code>OnAppEvent</code> trigger). This is normally done using the Appmixer JavaScript SDK or an HTTP request:</p>
<pre>
<code>
appmixer.api.sendAppEvent('contact-created', { first: 'David', last: 'Doe' });
</code>
or:
<code>
curl -XPOST \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer VIRTUAL_USER_ACCESS_TOKEN" \
-d '{ "first": "David", "last": "Doe" }' \
"https://APPMIXER_TENANT_API_URL/plugins/appmixer/utils/appevents/events/contact-created"
</code>
</pre>
<p><b>In this demo, you can send an App Event using the helper form below. This is to simulate a real-world scenario where you would send an App Event from your own application code.</b></p>
<form class="app-event-form">
<label>App Event name</label><input class="app-event-event" type="text" value="contact-created" placeholder="contact-created" />
<label>App Event data (JSON)</label><textarea class="app-event-data" placeholder="JSON data">{ "first": "David", "last": "Doe" }</textarea>
<input type="submit" value="Send App Event" />
</form>
<a id="github-link" href="https://github.com/clientIO/appmixer-demo-embedded-integrations" target="_blank"><img src="./assets/github-mark.svg" /></a>
</div>
<div class="app">
<div id="appmixer-integrations-marketplace"></div>
<div id="appmixer-integrations-logs"></div>
</div>
</div>
<script>
function loadScript(url, callback) {
const script = document.createElement('script');
script.src = url;
script.onload = callback;
script.onerror = console.error;
document.head.appendChild(script);
}
// The Appmixer SDK is located at https://my.YOUR_TENANT.appmixer.cloud/appmixer/appmixer.js.
let APPMIXER_STUDIO_URL = (new URLSearchParams(window.location.search)).get('studioUrl');
if (!APPMIXER_STUDIO_URL) {
APPMIXER_STUDIO_URL = prompt('Please provide your Appmixer Studio URL (https://my.YOUR_TENANT.appmixer.cloud).');
}
loadScript(APPMIXER_STUDIO_URL + '/appmixer/appmixer.js', () => {
loadScript('./main.js');
});
</script>
</body>
</html>