Docs »

Plugins »

Extension Points »

Bot Action

Name: Bot Action
Identifier (ID): devblocks.event.action

Manifest


		<extension point="devblocks.event.action">
			<id>example.bot.action</id>
			<name>Example Bot Action</name>
			<class>
				<file>api/App.php</file>
				<name>BotAction_Example</name>
			</class>
			<params>
				<param key="label" value="Example Bot Action"/>
				<param key="events">
					<value>
						<data key="*"/>
					</value>
				</param>
			</params>
		</extension>

Params

  • label: The human-friendly name for this action shown in the actions menu when building bots.

  • events: The bot events where this action is available. One entry per data key. Wildcards can be used with an asterisk (*), and a single asterisk key adds the action to all events.

Code



class BotAction_Example extends Extension_DevblocksEventAction {
	const ID = 'example.bot.action';

	/**
	 * Render the behavior action's configuration template.
	 */
	public function render(Extension_DevblocksEvent $event, Model_TriggerEvent $trigger, $params=[], $seq=NULL) {
		$tpl = DevblocksPlatform::services()->template();
		$tpl->assign('params', $params);
		
		if(!is_null($seq))
			$tpl->assign('namePrefix', 'action'.$seq);
		
		$tpl->display('devblocks:example.plugin::bot_actions/action_example.tpl');
	}

	/**
	 * Simulate the behavior action.
	 */
	public function simulate($token, Model_TriggerEvent $trigger, $params, DevblocksDictionaryDelegate $dict) {
		@$object_placeholder = $params['object_placeholder'] ?: '_placeholder';
		
		// Run the action in the simulator
		$this->run($token, $trigger, $params, $dict);
		
		// Return some simulator output
		$out = sprintf(">>> {{%s}}:\n%s\n",
			$object_placeholder,
			$dict->get($object_placeholder)
		);
		
		return $out;
	}

	/**
	 * Run the behavior action.
	 */
	public function run($token, Model_TriggerEvent $trigger, $params, DevblocksDictionaryDelegate $dict) {
		@$object_placeholder = $params['object_placeholder'] ?: '_placeholder';
		@$content = $params['content'];
		
		$tpl_builder = DevblocksPlatform::services()->templateBuilder();
		
		$output = $tpl_builder->build($content, $dict);
		
		$dict->set($object_placeholder, $output);
	}
};


Extensions

Classifier Prediction core.va.action.classifier_prediction
Create Attachment core.va.action.create_attachment
Create Domain va.action.create_domain
Create Opportunity va.action.create_opportunity
Create Reminder core.bot.action.create_reminder
Create Server va.action.create_server
Data Query core.bot.action.data_query
Email Parser core.bot.action.email_parser
Get time elapsed using calendar availability core.bot.action.calculate_time_elapsed
HTTP Request core.va.action.http_request
Log Call Global Event Action calls.event.action.post
PGP Encrypt core.bot.action.pgp.encrypt
Package Import core.bot.action.package.import
Record Create core.bot.action.record.create
Record Delete core.bot.action.record.delete
Record Retrieve core.bot.action.record.retrieve
Record Search core.bot.action.record.search
Record Update core.bot.action.record.update
Record Upsert core.bot.action.record.upsert
Schedule Proactive Interaction core.bot.action.interaction_proactive.schedule
Service AWS Get Pre-signed URL wgm.aws.bot.action.get_presigned_url