Skip to content

A php version of SDK for the development of custom actions for Rasa Core.

License

Notifications You must be signed in to change notification settings

ibagayoko/rc_sdk_php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rasa PHP-SDK

PHP SDK for the development of custom actions for Rasa Core.

Compatibility

SDK version compatible Rasa Core version
0.1.x >=0.12.x

Installation

To install the SDK run

composer require ibagayoko/rc_sdk_php

Usage

Can find detailed instructions about Custom Actions in the Rasa Core Documentation. Custom Actions. In your acion endpoint config file put:

action_endpoint:
  url: http://path-to.php/webhook

Simple PHP app

require "vendor/autoload.php";

use IBagayoko\RasaCoreSdk\Endpoint;
use IBagayoko\RasaCoreSdk\Action;
use IBagayoko\RasaCoreSdk\Events;

class PhpAction extends Action 
{
    public function name()
    {
        return "action_php";
    }
    public function run($dispatcher, $tracker, $domain)
    {
        $dispatcher->utter_message("Hello From Php");
        return [Events::SlotSet("php", "up")];
    }
}

// create a new endpoint with an array of customs actions
$endpoint = new Endpoint([PhpAction::class]);

switch ($_SERVER["PATH_INFO"]) {
    case '/health':
        $endpoint->health();
        break;
    case '/webhook':
        $endpoint->webhook();
    default:
        break;
}

Laravel Usage

use IBagayoko\RasaCoreSdk\Endpoint;
use IBagayoko\RasaCoreSdk\Action;
use IBagayoko\RasaCoreSdk\Events;

class PhpAction extends Action 
{
    public function name()
    {
        return "action_php";
    }
    public function run($dispatcher, $tracker, $domain)
    {
        $dispatcher->utter_message("Hello From Php");
        return [Events::SlotSet("php", "up")];
    }
}

// create a new endpoint with an array of customs actions
$endpoint = new Endpoint([PhpAction::class]);

Route::get('/health', function () use($endpoint)
{
	  return $endpoint->health();
});

Route::post('/webhook', function () use($endpoint)
{
	 return $endp->webhook();
});

License

Licensed under the Apache License, Version 2.0. Copy of the license.

About

A php version of SDK for the development of custom actions for Rasa Core.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages