flow_chat 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/README.md +408 -102
- data/examples/initializer.rb +1 -1
- data/examples/media_prompts_examples.rb +27 -0
- data/examples/multi_tenant_whatsapp_controller.rb +60 -64
- data/examples/ussd_controller.rb +17 -11
- data/examples/whatsapp_controller.rb +11 -12
- data/examples/whatsapp_media_examples.rb +404 -0
- data/examples/whatsapp_message_job.rb +111 -0
- data/lib/flow_chat/base_processor.rb +8 -4
- data/lib/flow_chat/config.rb +37 -0
- data/lib/flow_chat/session/cache_session_store.rb +5 -5
- data/lib/flow_chat/simulator/controller.rb +78 -0
- data/lib/flow_chat/simulator/views/simulator.html.erb +1982 -0
- data/lib/flow_chat/ussd/gateway/nsano.rb +1 -1
- data/lib/flow_chat/ussd/processor.rb +1 -2
- data/lib/flow_chat/ussd/prompt.rb +39 -5
- data/lib/flow_chat/version.rb +1 -1
- data/lib/flow_chat/whatsapp/app.rb +8 -2
- data/lib/flow_chat/whatsapp/client.rb +435 -0
- data/lib/flow_chat/whatsapp/configuration.rb +50 -12
- data/lib/flow_chat/whatsapp/gateway/cloud_api.rb +113 -115
- data/lib/flow_chat/whatsapp/middleware/executor.rb +1 -1
- data/lib/flow_chat/whatsapp/processor.rb +1 -11
- data/lib/flow_chat/whatsapp/prompt.rb +125 -84
- data/lib/flow_chat/whatsapp/send_job_support.rb +79 -0
- data/lib/flow_chat/whatsapp/template_manager.rb +7 -7
- metadata +8 -3
- data/lib/flow_chat/ussd/simulator/controller.rb +0 -51
- data/lib/flow_chat/ussd/simulator/views/simulator.html.erb +0 -239
@@ -0,0 +1,78 @@
|
|
1
|
+
module FlowChat
|
2
|
+
module Simulator
|
3
|
+
module Controller
|
4
|
+
def flowchat_simulator
|
5
|
+
respond_to do |format|
|
6
|
+
format.html do
|
7
|
+
render inline: simulator_view_template, layout: false, locals: simulator_locals
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
def default_phone_number
|
15
|
+
"+233244123456"
|
16
|
+
end
|
17
|
+
|
18
|
+
def default_contact_name
|
19
|
+
"John Doe"
|
20
|
+
end
|
21
|
+
|
22
|
+
def default_config_key
|
23
|
+
"ussd"
|
24
|
+
end
|
25
|
+
|
26
|
+
def simulator_configurations
|
27
|
+
{
|
28
|
+
"ussd" => {
|
29
|
+
name: "USSD (Nalo)",
|
30
|
+
description: "Local development USSD testing",
|
31
|
+
processor_type: "ussd",
|
32
|
+
provider: "nalo",
|
33
|
+
endpoint: "/ussd",
|
34
|
+
icon: "📱",
|
35
|
+
color: "#28a745",
|
36
|
+
settings: {
|
37
|
+
phone_number: default_phone_number,
|
38
|
+
session_timeout: 300
|
39
|
+
}
|
40
|
+
},
|
41
|
+
"whatsapp" => {
|
42
|
+
name: "WhatsApp",
|
43
|
+
description: "Local development WhatsApp testing",
|
44
|
+
processor_type: "whatsapp",
|
45
|
+
provider: "cloud_api",
|
46
|
+
endpoint: "/whatsapp/webhook",
|
47
|
+
icon: "💬",
|
48
|
+
color: "#25D366",
|
49
|
+
settings: {
|
50
|
+
phone_number: default_phone_number,
|
51
|
+
contact_name: default_contact_name,
|
52
|
+
verify_token: "local_verify_token",
|
53
|
+
webhook_url: "http://localhost:3000/whatsapp/webhook"
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
def simulator_view_template
|
60
|
+
File.read simulator_view_path
|
61
|
+
end
|
62
|
+
|
63
|
+
def simulator_view_path
|
64
|
+
File.join FlowChat.root.join("flow_chat", "simulator", "views", "simulator.html.erb")
|
65
|
+
end
|
66
|
+
|
67
|
+
def simulator_locals
|
68
|
+
{
|
69
|
+
pagesize: FlowChat::Config.ussd.pagination_page_size,
|
70
|
+
default_phone_number: default_phone_number,
|
71
|
+
default_contact_name: default_contact_name,
|
72
|
+
default_config_key: default_config_key,
|
73
|
+
configurations: simulator_configurations
|
74
|
+
}
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|