-
Notifications
You must be signed in to change notification settings - Fork 1
/
sample.js
41 lines (37 loc) · 1.2 KB
/
sample.js
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
const MxSdk = require('machaao');
const express = require('express');
const server = express();
const lib = new MxSdk('<Bot-Token>', 'prod', server);
server.post('/incoming', async (req, res) => {
let x = await lib.getUserMessages(req); // read incoming user messages
await lib.sendTextMessage(req, 'hi');
await lib.sendButtonsOrQuickRepliesMessage(
req,
'test buttons',
[{ title: 'button', type: 'postback', payload: 'Hi' }], // sample buttons
[{ title: 'qr', content_type: 'text', payload: 'qr' }] // sample quick reply
);
//sample carousel
await lib.sendCarousel(req, 'test carousel', [
{
title: 'title',
subtitle: 'subtitle',
image_url: 'https://provogue.s3.amazonaws.com/provogue-duffle1.jpg',
buttons: [{ title: 'button', type: 'postback', payload: 'Hi' }],
},
{
title: 'title',
subtitle: 'subtitle',
image_url: 'https://provogue.s3.amazonaws.com/provogue-duffle1.jpg',
buttons: [{ title: 'button', type: 'postback', payload: 'Hi' }],
},
{
title: 'title',
subtitle: 'subtitle',
image_url: 'https://provogue.s3.amazonaws.com/provogue-duffle1.jpg',
buttons: [{ title: 'button', type: 'postback', payload: 'Hi' }],
},
]);
res.send(200);
});
server.listen(3000);