-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
95 lines (78 loc) · 3.88 KB
/
index.php
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
/////////LINK PAGINA ->https://credifintechdurango.herokuapp.com/
////////////////
///////////
//Este archivo importa todos los drivers necesarios para imoprtarlos con "use"
require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/vendor/botman/botman/src/Interfaces/UserInterface.php';
require __DIR__ . '/vendor/botman/driver-facebook/src/FacebookDriver.php';
require __DIR__ . '/vendor/botman/botman/src/BotMan.php';
require __DIR__ . '/vendor/botman/botman/src/Drivers/Tests/ProxyDriver.php';
//Importando archivos necesarios
require_once __DIR__."/src/Constantes.php";
require_once __DIR__."/src/conversations/instituciones/TipoInstitucionConversation.php";
require_once __DIR__."/src/conversations/MenuConversation.php";
require_once __DIR__."/src/conversations/SalidaConversation.php";
//Extra Facebook Drivers
//require_once __DIR__."/vendor/botman/driver-facebook/src/FacebookDriver.php";
require_once __DIR__."/vendor/botman/driver-facebook/src/FacebookImageDriver.php";
require_once __DIR__."/vendor/botman/driver-facebook/src/FacebookFileDriver.php";
//Configurando namespace de clases de botman (Plantillas de facebook)
use BotMan\BotMan\BotMan;
use BotMan\BotMan\BotManFactory;
use BotMan\BotMan\Drivers\DriverManager;
use BotMan\Drivers\Facebook\Extensions\ButtonTemplate;
use BotMan\Drivers\Facebook\Extensions\ElementButton;
use BotMan\Drivers\Facebook\Extensions\Message;
use BotMan\Drivers\Facebook\Extensions\Element;
use BotMan\BotMan\Messages\Conversations\Conversation;
use BotMan\BotMan\Messages\Outgoing\Question;
use BotMan\BotMan\Messages\Outgoing\Actions\Button;
use BotMan\BotMan\Cache\DoctrineCache;
use Doctrine\Common\Cache\FilesystemCache;
//Configurando namespace de clases personalizadas
use BotCredifintech\Constantes;
use BotCredifintec\Conversations\Instituciones\TipoInsitucionConversation;
use BotCredifintech\Conversations\MenuConversation;
use BotCredifintech\Conversations\SalidaConversation;
//Ca,
// Driver de chatbot para Facebook
DriverManager::loadDriver(\BotMan\Drivers\Facebook\FacebookDriver::class);
DriverManager::loadDriver(\Botman\Drivers\Facebook\FacebookImageDriver::class);
DriverManager::loadDriver(\Botman\Drivers\Facebook\FacebookFileDriver::class);
$config = [
'facebook' =>
//VILLAHERMOSA
[
'token' => 'EAASXewHWGFEBAGcGhrJPKElXI9t2EMjlZC5nSey2xN2prScJ8axwaS7ZC7Ltv9FATclm219fwctJqancKlvI4qU57Pag5fGh0TpVRZCP5XwEi0AsE94h6u9J48cI5wxvq7IVVGGEiZCGnp0kYWysUz98tkIXUo6bmXsZCUhD6LqmOLKYhce3T',
'app_secret' => 'de8f0b94310a8a7c6b032d0dc4a4dd1d',
'verification'=>'d8wkg9wkflaaeha54qyhf5yadfjaibs3iwro203852',
],
[
'token' => 'EAAGrT16HtJgBALXkCgeR29RFU2YZCm8xgPewUOjr6aDdxcu8CrqGeX4NbgpcSBcEjLjhsXZABZCr5l93I1cuAG68KSD6AKSsmb0koPvK2tmtoRViP6fOw1fAZCH2NZBtg5NI8UYkTzzMCuul28fPBEZBPZBaNGvwb8KZCpEMaMxyOA9XuWBDFYYq',
'app_secret' => 'e4647b87a6b18da6803bddc3b3349674',
'verification'=>'d8wkg9wkflaaeha54qyhf5yadfjaibs3iwro203852',
]
];
$doctrineCacheDriver = new FilesystemCache(__DIR__);
$botman = BotManFactory::create($config, new DoctrineCache($doctrineCacheDriver));
$botman->hears('^(?!.*\basesor|ASESOR|Asesor\b).*$', function (BotMan $bot) {
/*$nombre = $bot->getUser()->getFirstName();
$incomingMessageText = $bot->getMessage()->getText();
$nombre = $bot->getUser()->getFirstName();*/
$bot -> reply("Bienvenido a Credifintech, es un Placer Atenderle.");
$bot -> reply(Constantes::EXPLICAR_SERVICIO);
$bot->reply("Para regresar a este menú, escriba la palabra 'menu' en cualquier parte de la conversación");
$bot -> startConversation(new MenuConversation(""));
});
$botman->hears('no', function (BotMan $bot) {
$bot->reply('no 🤘');
});
$botman->hears('.*(Menu|menu|Menú|MENU|menú).*', function(BotMan $bot) {
})->stopsConversation();
$botman->hears('.*(asesor|ASESOR|Asesor).*', function(BotMan $bot) {
$bot->reply(Constantes::MENSAJE_AYUDA_ASESOR);
})->stopsConversation();
$botman->listen();
//echo "This is botman running";
?>