-
Notifications
You must be signed in to change notification settings - Fork 1
/
bot session created.crm
34 lines (26 loc) · 1.06 KB
/
bot session created.crm
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
#setLanguageLevel 3;
EventData ed = getEventData();
String botName = ed.getInputValue("chatTopic.botName");
Integer sessionId = ed.getInputValue("chatSession.id").toInteger();
Integer toCustomer = 1;
// Connect to the back end botkit
// {"type":"welcome_back","user":"6bbc3a64-376d-d487-b636-3ad22f4ffa7e","channel":"webhook"}
JSONBuilder js;
js.setPrettyPrint(4);
js.pushObject("");
js.addString("type", "welcome_back");
js.addString("user", sessionId.toString());
js.addString("channel", "webhook");
js.popLevel();
js.finalize();
Byte[] data = js.getString().toByteArray();
HTTP http;
http.addHeader("Accept", "application/json");
http.addHeader("Content-type", "application/json");
http.addBinaryData(data);
Byte[] bytes = http.post("https://crm-sod.superoffice.com/botkit/api/messages");
String s = String(bytes);
// No response
String message = "Botkit echo until you say 'human' to transfer. Say 'quit' to stop.";
addChatMessage(sessionId, message, toCustomer, botName, 0, "" );
// This fires before FAQ has been answered for example.