custom Communication Provider

You are using a SMS/FAX provider the Communicate Feature of Workflow Designer do not support? That’s no problem if you could develop your own PHP interface. You also could ask our team if we should do this for you.

You need to add one file to folder modules/Workflow2/extends/communicate with the filename <individual>.inc.php

The structure of this file have to be:

<?php

namespace Workflow\CommunicationProvider;

use Workflow\VtUtils;

class ProviderName extends \Workflow\CommunicationPlugin
{
    // Allow you to rename the username field in configuration, without the requirement to add custom fields
	protected $usernameLabel = 'Account SID';
	// Allow you to rename the password field in configuration, without the requirement to add custom fields
    protected $passwordLabel = 'Auth Token';

	// Visible name of your provider
    protected $name = 'ProviderName';

	// Which feature is supported (Currently only sms available, fax will be added soon)
    protected $supported = array(
        'sms' => true
    );

	/**
	 * Function to send the SMS
	 * @var $data array
	 *
	 * @return void
	 */
    public function SMS($data) {
		// $data will contain configuration from task
		// $this->get('key') allows you to load configuration
		
        $sid = $this->get('username');
        $token = $this->get('password');

        $parameter = array(
            'To' => ($data['to']),
            'From' => ($data['from']),
            'Body' => $data['content']
        );

    }

	/**
	 * Function will test configuration
	 * $this->get('key') allows you to load configuration
	 *
	 * @throws Exception if configuration is not valid
	 */
    public function test() {
			
        $sid = $this->get('username');
        $token = $this->get('password');

        
        if(empty($response)) {
            throw new \Exception('Error happen');
        }

    }

	/**
	 * Function to get all configuration fields
	 */
    public function getConfigFields()
    {
        $return = parent::getConfigFields();
        $return['default_from'] = array(
            'label' => 'Default Sender',
            'type' => 'text',
        );

        return $return;
    }

    /**
	 * Add Data fields for Task config
	 */
    public function getDataFields($method) {
        $return = parent::getDataFields($method);
        $return['from']['placeholder'] = $this->get('default_from');
        return $return;
    }

}

// Register your provider
\Workflow\CommunicationPlugin::register('providerkey', '\Workflow\CommunicationProvider\ProviderName');
Artikel-PDF herunterladen